diff options
author | Karsten Blees <blees@dcon.de> | 2014-07-17 17:38:04 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-07-21 09:32:50 -0700 |
commit | 343ff06da7d83f40892b10a3b653c7d0e6cb526c (patch) | |
tree | 0119633d4a181d4a290635db01ea0e481f5af960 /t/t1051-large-conversion.sh | |
parent | Win32: use low-level memory allocation during initialization (diff) | |
download | tgif-343ff06da7d83f40892b10a3b653c7d0e6cb526c.tar.xz |
Win32: keep the environment sorted
The Windows environment is sorted, keep it that way for O(log n)
environment access.
Change compareenv to compare only the keys, so that it can be used to
find an entry irrespective of the value.
Change lookupenv to binary seach for an entry. Return one's complement of
the insert position if not found (libc's bsearch returns NULL).
Replace MSVCRT's getenv with a minimal do_getenv based on the binary search
function.
Change do_putenv to insert new entries at the correct position. Simplify
the function by swapping if conditions and using memmove instead of for
loops.
Move qsort from make_environment_block to mingw_startup. We still need to
sort on startup to make sure that the environment is sorted according to
our compareenv function (while Win32 / CreateProcess requires the
environment block to be sorted case-insensitively, CreateProcess currently
doesn't enforce this, and some applications such as bash just don't care).
Note that environment functions are _not_ thread-safe and are not required
to be so by POSIX, the application is responsible for synchronizing access
to the environment. MSVCRT's getenv and our new getenv implementation are
better than that in that they are thread-safe with respect to other getenv
calls as long as the environment is not modified. Git's indiscriminate use
of getenv in background threads currently requires this property.
Signed-off-by: Karsten Blees <blees@dcon.de>
Signed-off-by: Stepan Kasal <kasal@ucw.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1051-large-conversion.sh')
0 files changed, 0 insertions, 0 deletions