extent_mmap.c revision 1.1.1.1
1#define JEMALLOC_EXTENT_MMAP_C_ 2#include "jemalloc/internal/jemalloc_preamble.h" 3#include "jemalloc/internal/jemalloc_internal_includes.h" 4 5#include "jemalloc/internal/assert.h" 6#include "jemalloc/internal/extent_mmap.h" 7 8/******************************************************************************/ 9/* Data. */ 10 11bool opt_retain = 12#ifdef JEMALLOC_RETAIN 13 true 14#else 15 false 16#endif 17 ; 18 19/******************************************************************************/ 20 21void * 22extent_alloc_mmap(void *new_addr, size_t size, size_t alignment, bool *zero, 23 bool *commit) { 24 void *ret = pages_map(new_addr, size, ALIGNMENT_CEILING(alignment, 25 PAGE), commit); 26 if (ret == NULL) { 27 return NULL; 28 } 29 assert(ret != NULL); 30 if (*commit) { 31 *zero = true; 32 } 33 return ret; 34} 35 36bool 37extent_dalloc_mmap(void *addr, size_t size) { 38 if (!opt_retain) { 39 pages_unmap(addr, size); 40 } 41 return opt_retain; 42} 43