MCPcopy Index your code
hub / github.com/GJDuck/e9patch / reserve

Function reserve

src/e9patch/e9alloc.cpp:598–619  ·  view source on GitHub ↗

* Reserves a chunk of the virtual address space spanning the range [lb..ub]. * Returns `true` on success, `false` on failure. */

Source from the content-addressed store, hash-verified

596 * Returns `true` on success, `false` on failure.
597 */
598bool reserve(Binary *B, intptr_t lb, intptr_t ub)
599{
600 Allocator &allocator = B->allocator;
601 if (!verify(lb, ub))
602 return false;
603 lb -= (lb % PAGE_SIZE);
604 ub += (ub % PAGE_SIZE == 0? 0: PAGE_SIZE - ub % PAGE_SIZE);
605 if (ub - lb <= 0)
606 return false;
607 uint32_t flags = 0;
608 Node *n = insert(allocator.tree.root, lb, ub, (ub - lb), flags);
609 if (n == nullptr)
610 return false;
611 if (allocator.tree.root == nullptr)
612 allocator.tree.root = n;
613 rebalanceInsert(&allocator.tree, n);
614
615 Alloc *A = &n->alloc;
616 A->T = nullptr;
617 A->I = nullptr;
618 return true;
619}
620
621/*
622 * Deallocate an existing allocation.

Callers 3

parseElfFunction · 0.85
parsePEFunction · 0.85
parseReserveFunction · 0.85

Calls 3

verifyFunction · 0.85
rebalanceInsertFunction · 0.85
insertFunction · 0.70

Tested by

no test coverage detected