summaryrefslogtreecommitdiff
path: root/headers.c
diff options
context:
space:
mode:
Diffstat (limited to 'headers.c')
-rw-r--r--headers.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/headers.c b/headers.c
index 69f15751..ea83378e 100644
--- a/headers.c
+++ b/headers.c
@@ -129,25 +129,21 @@ GC_INNER ptr_t GC_scratch_alloc(size_t bytes)
if (bytes_to_get <= bytes) {
/* Undo the damage, and get memory directly */
- bytes_to_get = bytes;
-# ifdef USE_MMAP
- bytes_to_get = ROUNDUP_PAGESIZE(bytes_to_get);
-# endif
+ bytes_to_get = ROUNDUP_PAGESIZE_IF_MMAP(bytes);
result = (ptr_t)GET_MEM(bytes_to_get);
GC_add_to_our_memory(result, bytes_to_get);
scratch_free_ptr -= bytes;
GC_scratch_last_end_ptr = result + bytes;
return(result);
}
+
+ bytes_to_get = ROUNDUP_PAGESIZE_IF_MMAP(bytes_to_get); /* for safety */
result = (ptr_t)GET_MEM(bytes_to_get);
GC_add_to_our_memory(result, bytes_to_get);
if (result == 0) {
WARN("Out of memory - trying to allocate less\n", 0);
scratch_free_ptr -= bytes;
- bytes_to_get = bytes;
-# ifdef USE_MMAP
- bytes_to_get = ROUNDUP_PAGESIZE(bytes_to_get);
-# endif
+ bytes_to_get = ROUNDUP_PAGESIZE_IF_MMAP(bytes);
result = (ptr_t)GET_MEM(bytes_to_get);
GC_add_to_our_memory(result, bytes_to_get);
return result;