31template <
typename Character>
42 size_t entry_count = 0;
43 for (Character** it = old_environment; *it; ++it)
49 __crt_unique_heap_ptr<Character*> new_environment(_calloc_crt_t(Character*, entry_count + 1));
55 Character** old_it = old_environment;
56 Character** new_it = new_environment.get();
57 for (; *old_it; ++old_it, ++new_it)
59 size_t const required_count = traits::tcslen(*old_it) + 1;
60 *new_it = _calloc_crt_t(Character, required_count).detach();
66 _ERRCHECK(traits::tcscpy_s(*new_it, required_count, *old_it));
69 return new_environment.detach();
78template <
typename Character>
95template <
typename Character>
97 Character
const*
const name,
105 Character** it =
nullptr;
106 for (it = environment; *it; ++it)
109 if (traits::tcsnicoll(
name, *it,
length) != 0)
121 return static_cast<ptrdiff_t>(it - environment);
125 return -
static_cast<ptrdiff_t>(it - environment);
163template <
typename Character>
166 int const is_top_level_call
174 __crt_unique_heap_ptr<Character> owned_option(
option);
176 Character*
const equal_sign = traits::tcschr(
option,
'=');
187 bool const is_removal = *(equal_sign + 1) ==
'\0';
194 ensure_current_environment_is_not_initial_environment_nolock<Character>();
210 ensure_current_environment_is_not_initial_environment_nolock<Character>();
254 _ASSERTE((
"CRT logic error in setenv", 0));
263 if (option_index >= 0 && environment[0])
271 size_t i =
static_cast<size_t>(option_index);
272 for (; environment[
i]; ++
i)
274 environment[
i] = environment[
i + 1];
281 Character** new_environment = _recalloc_crt_t(Character*, environment,
i).detach();
290 environment[option_index] = owned_option.detach();
305 size_t const environment_count =
static_cast<size_t>(-option_index);
306 if (environment_count + 2 < environment_count)
311 if (environment_count + 2 >=
SIZE_MAX /
sizeof(Character*))
316 Character**
const new_environment = _recalloc_crt_t(Character*, environment, environment_count + 2).detach();
317 if (!new_environment)
322 new_environment[environment_count] = owned_option.detach();
323 new_environment[environment_count + 1] =
nullptr;
334 if (is_top_level_call)
337 __crt_unique_heap_ptr<Character>
const buffer(_calloc_crt_t(Character,
count));
349 if (traits::set_environment_variable(
name, is_removal ?
nullptr :
value) == 0)
361 int const is_top_level_call
369 int const is_top_level_call
result_buffer_count char *const _In_ int const _In_ bool const _In_ unsigned const _In_ STRFLT const _In_ bool const _Inout_ __crt_cached_ptd_host &ptd throw()
__kernel_ptrdiff_t ptrdiff_t
__crt_state_management::dual_state_global< wchar_t ** > _wenviron_table
__crt_state_management::dual_state_global< char ** > _environ_table
wchar_t ** __dcrt_initial_wide_environment
char ** __dcrt_initial_narrow_environment
GLuint GLuint GLsizei count
GLuint GLsizei GLsizei * length
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
#define _VALIDATE_RETURN_NOEXC(expr, errorcode, retexpr)
static void __cdecl ensure_current_environment_is_not_initial_environment_nolock()
static char **&__cdecl get_initial_environment(char)
int __cdecl __dcrt_set_variable_in_narrow_environment_nolock(char *const option, int const is_top_level_call)
static int __cdecl common_set_variable_in_environment_nolock(Character *const option, int const is_top_level_call)
static wchar_t **&__cdecl get_other_environment(char)
static ptrdiff_t __cdecl find_in_environment_nolock(Character const *const name, size_t const length)
int __cdecl __dcrt_set_variable_in_wide_environment_nolock(wchar_t *const option, int const is_top_level_call)
static char **&__cdecl get_environment(char)
static Character **__cdecl copy_environment(Character **const old_environment)