MCPcopy Create free account
hub / github.com/beefytech/Beef / os_pages_commit

Function os_pages_commit

BeefRT/JEMalloc/src/pages.c:318–345  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

316}
317
318static bool
319os_pages_commit(void *addr, size_t size, bool commit) {
320 assert(PAGE_ADDR2BASE(addr) == addr);
321 assert(PAGE_CEILING(size) == size);
322
323#ifdef _WIN32
324 return (commit ? (addr != VirtualAlloc(addr, size, MEM_COMMIT,
325 PAGE_READWRITE)) : (!VirtualFree(addr, size, MEM_DECOMMIT)));
326#else
327 {
328 int prot = commit ? PAGES_PROT_COMMIT : PAGES_PROT_DECOMMIT;
329 void *result = mmap(addr, size, prot, mmap_flags | MAP_FIXED,
330 PAGES_FD_TAG, 0);
331 if (result == MAP_FAILED) {
332 return true;
333 }
334 if (result != addr) {
335 /*
336 * We succeeded in mapping memory, but not in the right
337 * place.
338 */
339 os_pages_unmap(result, size);
340 return true;
341 }
342 return false;
343 }
344#endif
345}
346
347static bool
348pages_commit_impl(void *addr, size_t size, bool commit) {

Callers 3

pages_commit_implFunction · 0.85
pages_mark_guardsFunction · 0.85
pages_unmark_guardsFunction · 0.85

Calls 1

mmapFunction · 0.50

Tested by

no test coverage detected