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

Function malloc_fix_invariant

examples/stdlib.c:1827–1843  ·  view source on GitHub ↗

* Fix the interval-tree invariant (RB-tree augmentation). */

Source from the content-addressed store, hash-verified

1825 * Fix the interval-tree invariant (RB-tree augmentation).
1826 */
1827static void malloc_fix_invariant(struct malloc_pool_s *pool, uint32_t n)
1828{
1829 if (n == MA_NIL)
1830 return;
1831 uint32_t l = MA_LEFT(pool, n), r = MA_RIGHT(pool, n);
1832 uint32_t llb = (l != MA_NIL? MA_LB(pool, l): MA_POOL_UB(pool));
1833 intptr_t rub = (r != MA_NIL? MA_UB(pool, r): MA_POOL_LB(pool));
1834 MA_LB(pool, n) = MA_MIN(llb, n);
1835 MA_UB(pool, n) = MA_MAX(rub, n + MA_SIZE(pool, n));
1836 uint32_t lgap = (l != MA_NIL? MA_GAP(pool, l): 0);
1837 uint32_t rgap = (r != MA_NIL? MA_GAP(pool, r): 0);
1838 uint32_t gap = MA_MAX(lgap, rgap);
1839 gap = MA_MAX(gap, (uint32_t)(l != MA_NIL? n - MA_UB(pool, l): 0));
1840 gap = MA_MAX(gap, (uint32_t)(r != MA_NIL?
1841 MA_LB(pool, r) - (n + MA_SIZE(pool, n)): 0));
1842 MA_GAP(pool, n) = gap;
1843}
1844
1845static void malloc_rotate_left(struct malloc_pool_s *pool, uint32_t n)
1846{

Callers 5

malloc_rotate_leftFunction · 0.85
malloc_rotate_rightFunction · 0.85
malloc_rebalance_insertFunction · 0.85
malloc_removeFunction · 0.85
realloc_implFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected