MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / traverse_and_check

Function traverse_and_check

system/lib/dlmalloc.c:3504–3532  ·  view source on GitHub ↗

Traverse each chunk and check it; return total */

Source from the content-addressed store, hash-verified

3502
3503/* Traverse each chunk and check it; return total */
3504static size_t traverse_and_check(mstate m) {
3505 size_t sum = 0;
3506 if (is_initialized(m)) {
3507 msegmentptr s = &m->seg;
3508 sum += m->topsize + TOP_FOOT_SIZE;
3509 while (s != 0) {
3510 mchunkptr q = align_as_chunk(s->base);
3511 mchunkptr lastq = 0;
3512 assert(pinuse(q));
3513 while (segment_holds(s, q) &&
3514 q != m->top && q->head != FENCEPOST_HEAD) {
3515 sum += chunksize(q);
3516 if (is_inuse(q)) {
3517 assert(!bin_find(m, q));
3518 do_check_inuse_chunk(m, q);
3519 }
3520 else {
3521 assert(q == m->dv || bin_find(m, q));
3522 assert(lastq == 0 || is_inuse(lastq)); /* Not 2 consecutive free */
3523 do_check_free_chunk(m, q);
3524 }
3525 lastq = q;
3526 q = next_chunk(q);
3527 }
3528 s = s->next;
3529 }
3530 }
3531 return sum;
3532}
3533
3534
3535/* Check all properties of malloc_state. */

Callers 1

do_check_malloc_stateFunction · 0.85

Calls 4

bin_findFunction · 0.85
do_check_inuse_chunkFunction · 0.85
do_check_free_chunkFunction · 0.85
assertFunction · 0.50

Tested by

no test coverage detected