MCPcopy Create free account
hub / github.com/GJDuck/e9patch / fix

Function fix

src/e9patch/e9alloc.cpp:67–82  ·  view source on GitHub ↗

* Restore interval-tree invariants after a node after child node modification. */

Source from the content-addressed store, hash-verified

65 * Restore interval-tree invariants after a node after child node modification.
66 */
67static void fix(Node *n)
68{
69 if (n == nullptr)
70 return;
71 Node *l = n->entry.left, *r = n->entry.right;
72 intptr_t llb = (l != nullptr? l->lb: INTPTR_MAX);
73 intptr_t rub = (r != nullptr? r->ub: INTPTR_MIN);
74 n->lb = std::min(llb, n->alloc.lb);
75 n->ub = std::max(rub, n->alloc.ub);
76 uint64_t lgap = (l == nullptr? 0: l->gap);
77 uint64_t rgap = (r == nullptr? 0: r->gap);
78 uint64_t gap = std::max(lgap, rgap);
79 gap = std::max(gap, (uint64_t)(l == nullptr? 0: n->alloc.lb - l->ub));
80 gap = std::max(gap, (uint64_t)(r == nullptr? 0: r->lb - n->alloc.ub));
81 n->gap = gap;
82}
83
84/****************************************************************************/
85/* INTERVAL TREES */

Callers 4

rotateLeftFunction · 0.70
rotateRightFunction · 0.70
rebalanceInsertFunction · 0.70
removeFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected