diff options
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/alloc.c b/src/alloc.c index 0c18fca1755..8d0fdd125dc 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -196,6 +196,12 @@ static char *spare_memory[7]; | |||
| 196 | #define SPARE_MEMORY (1 << 14) | 196 | #define SPARE_MEMORY (1 << 14) |
| 197 | #endif | 197 | #endif |
| 198 | 198 | ||
| 199 | #ifdef SYSTEM_MALLOC | ||
| 200 | # define LARGE_REQUEST (1 << 14) | ||
| 201 | #else | ||
| 202 | # define LARGE_REQUEST SPARE_MEMORY | ||
| 203 | #endif | ||
| 204 | |||
| 199 | /* Number of extra blocks malloc should get when it needs more core. */ | 205 | /* Number of extra blocks malloc should get when it needs more core. */ |
| 200 | 206 | ||
| 201 | static int malloc_hysteresis; | 207 | static int malloc_hysteresis; |
| @@ -3283,15 +3289,12 @@ memory_full (size_t nbytes) | |||
| 3283 | { | 3289 | { |
| 3284 | /* Do not go into hysterics merely because a large request failed. */ | 3290 | /* Do not go into hysterics merely because a large request failed. */ |
| 3285 | int enough_free_memory = 0; | 3291 | int enough_free_memory = 0; |
| 3286 | if (SPARE_MEMORY < nbytes) | 3292 | if (LARGE_REQUEST < nbytes) |
| 3287 | { | 3293 | { |
| 3288 | void *p = malloc (SPARE_MEMORY); | 3294 | void *p = malloc (LARGE_REQUEST); |
| 3289 | if (p) | 3295 | if (p) |
| 3290 | { | 3296 | { |
| 3291 | if (spare_memory[0]) | 3297 | free (p); |
| 3292 | free (p); | ||
| 3293 | else | ||
| 3294 | spare_memory[0] = p; | ||
| 3295 | enough_free_memory = 1; | 3298 | enough_free_memory = 1; |
| 3296 | } | 3299 | } |
| 3297 | } | 3300 | } |