Commit 6f1c189
Win32: use low-level memory allocation during initialization
As of d41489a "Add more large blob test cases", git's high-level memory
allocation functions (xmalloc, xmemdupz etc.) access the environment to
simulate limited memory in tests (see 'getenv("GIT_ALLOC_LIMIT")' in
memory_limit_check()). These functions should not be used before the
environment is fully initialized (particularly not to initialize the
environment itself).
The current solution ('environ = NULL; ALLOC_GROW(environ...)') only works
because MSVCRT's getenv() reinitializes environ when it is NULL (i.e. it
leaves us with two sets of unusabe (non-UTF-8) and unfreeable (CRT-
allocated) environments).
Add our own set of malloc-or-die functions to be used in startup code.
Also check the result of __wgetmainargs, which may fail if there's not
enough memory for wide-char arguments and environment.
This patch is in preparation of the sorted environment feature, which
completely replaces MSVCRT's getenv() implementation.
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>1 parent f279242 commit 6f1c189
1 file changed
Lines changed: 28 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2033 | 2033 | | |
2034 | 2034 | | |
2035 | 2035 | | |
| 2036 | + | |
| 2037 | + | |
| 2038 | + | |
| 2039 | + | |
| 2040 | + | |
| 2041 | + | |
| 2042 | + | |
| 2043 | + | |
| 2044 | + | |
| 2045 | + | |
| 2046 | + | |
| 2047 | + | |
| 2048 | + | |
| 2049 | + | |
2036 | 2050 | | |
2037 | 2051 | | |
2038 | | - | |
| 2052 | + | |
2039 | 2053 | | |
2040 | 2054 | | |
2041 | 2055 | | |
| |||
2052 | 2066 | | |
2053 | 2067 | | |
2054 | 2068 | | |
2055 | | - | |
2056 | | - | |
| 2069 | + | |
| 2070 | + | |
| 2071 | + | |
| 2072 | + | |
| 2073 | + | |
2057 | 2074 | | |
2058 | | - | |
| 2075 | + | |
| 2076 | + | |
2059 | 2077 | | |
2060 | 2078 | | |
2061 | 2079 | | |
2062 | | - | |
| 2080 | + | |
2063 | 2081 | | |
2064 | 2082 | | |
2065 | | - | |
2066 | | - | |
2067 | | - | |
2068 | | - | |
2069 | | - | |
2070 | | - | |
2071 | | - | |
2072 | | - | |
2073 | | - | |
2074 | | - | |
| 2083 | + | |
| 2084 | + | |
| 2085 | + | |
| 2086 | + | |
| 2087 | + | |
2075 | 2088 | | |
2076 | 2089 | | |
2077 | 2090 | | |
| |||
0 commit comments