55template <
typename Character>
64 Character* it = environment_block;
71 it += traits::tcslen(it) + 1;
89template <
typename Character>
95 for (Character** it = environment; *it; ++it)
108template <
typename Character>
115 __crt_unique_heap_ptr<Character*> environment(_calloc_crt_t(Character*, variable_count + 1));
119 Character* source_it = environment_block;
120 Character** result_it = environment.get();
122 while (*source_it !=
'\0')
124 size_t const required_count = traits::tcslen(source_it) + 1;
127 if (*source_it !=
'=')
129 __crt_unique_heap_ptr<Character>
variable(_calloc_crt_t(Character, required_count));
141 source_it += required_count;
145 return environment.detach();
166template <
typename Character>
179 __crt_unique_heap_ptr<Character>
const os_environment(traits::get_environment_from_os());
183 __crt_unique_heap_ptr<Character*> crt_environment(
create_environment(os_environment.get()));
184 if (!crt_environment)
194 return common_initialize_environment_nolock<char>();
199 return common_initialize_environment_nolock<wchar_t>();
205template <
typename Character>
218 _environ_table .uninitialize(uninitialize_environment_internal<char>);
219 _wenviron_table.uninitialize(uninitialize_environment_internal<wchar_t>);
240template <
typename Character>
244 typedef typename traits::other_char_type other_char_type;
247 if (!other_environment)
250 for (other_char_type** it = other_environment; *it; ++it)
253 if (required_count == 0)
256 __crt_unique_heap_ptr<Character>
buffer(_calloc_crt_t(Character, required_count));
260 size_t const actual_count = __crt_transform_string(
CP_ACP, *it,
buffer.get(), required_count);
261 if (actual_count == 0)
265 traits::set_variable_in_environment_nolock(
buffer.detach(), 0);
277template <
typename Character>
282 typedef typename traits::other_char_type other_char_type;
286 if (existing_environment)
287 return existing_environment;
292 if (!other_environment)
295 if (common_initialize_environment_nolock<Character>() != 0)
297 if (initialize_environment_by_cloning_nolock<Character>() != 0)
308 return common_get_or_create_environment_nolock<char>();
313 return common_get_or_create_environment_nolock<wchar_t>();
316template <
typename Character>
320 if (!initial_environment)
322 initial_environment = common_get_or_create_environment_nolock<Character>();
325 return initial_environment;
330 return common_get_initial_environment<char>();
335 return common_get_initial_environment<wchar_t>();
bool __cdecl __acrt_initialize_multibyte(void)
size_t __crt_compute_required_transform_buffer_count(unsigned const code_page, _In_z_ char const *const string)
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()
char ***__cdecl __p__environ()
static int __cdecl common_initialize_environment_nolock()
char **__cdecl _get_initial_narrow_environment()
static _Ret_opt_z_ char **&__cdecl get_initial_environment(char)
__crt_state_management::dual_state_global< wchar_t ** > _wenviron_table
static Character **const create_environment(Character *const environment_block)
int __cdecl _initialize_wide_environment()
wchar_t **__cdecl __dcrt_get_or_create_wide_environment_nolock()
wchar_t **__cdecl _get_initial_wide_environment()
__crt_state_management::dual_state_global< char ** > _environ_table
static _Ret_opt_z_ char **& get_environment_nolock(char)
static size_t const count_variables_in_environment_block(Character *const environment_block)
static int __cdecl initialize_environment_by_cloning_nolock()
wchar_t ** __dcrt_initial_wide_environment
void __cdecl __dcrt_uninitialize_environments_nolock()
static void __cdecl uninitialize_environment_internal(Character **&environment)
static void free_environment(Character **const environment)
int __cdecl _initialize_narrow_environment()
static void pre_initialize(wchar_t)
static __crt_state_management::dual_state_global< char ** > & get_dual_state_environment_nolock(char)
static Character **__cdecl common_get_initial_environment()
static _Deref_ret_opt_z_ Character **__cdecl common_get_or_create_environment_nolock()
wchar_t ***__cdecl __p__wenviron()
char ** __dcrt_initial_narrow_environment
char **__cdecl __dcrt_get_or_create_narrow_environment_nolock()
GLuint GLuint GLsizei count
#define _Deref_ret_opt_z_