extent_mmap.c 901 B

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