MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / pages_commit_impl

Function pages_commit_impl

deps/jemalloc/src/pages.c:248–279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

246}
247
248static bool
249pages_commit_impl(void *addr, size_t size, bool commit) {
250 assert(PAGE_ADDR2BASE(addr) == addr);
251 assert(PAGE_CEILING(size) == size);
252
253 if (os_overcommits) {
254 return true;
255 }
256
257#ifdef _WIN32
258 return (commit ? (addr != VirtualAlloc(addr, size, MEM_COMMIT,
259 PAGE_READWRITE)) : (!VirtualFree(addr, size, MEM_DECOMMIT)));
260#else
261 {
262 int prot = commit ? PAGES_PROT_COMMIT : PAGES_PROT_DECOMMIT;
263 void *result = mmap(addr, size, prot, mmap_flags | MAP_FIXED,
264 -1, 0);
265 if (result == MAP_FAILED) {
266 return true;
267 }
268 if (result != addr) {
269 /*
270 * We succeeded in mapping memory, but not in the right
271 * place.
272 */
273 os_pages_unmap(result, size);
274 return true;
275 }
276 return false;
277 }
278#endif
279}
280
281bool
282pages_commit(void *addr, size_t size) {

Callers 2

pages_commitFunction · 0.70
pages_decommitFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected