MCPcopy Index your code
hub / github.com/dcodeIO/webassembly / traverse_and_check

Function traverse_and_check

lib/dlmalloc/malloc.c:3418–3446  ·  view source on GitHub ↗

Traverse each chunk and check it; return total */

Source from the content-addressed store, hash-verified

3416
3417/* Traverse each chunk and check it; return total */
3418static size_t traverse_and_check(mstate m) {
3419 size_t sum = 0;
3420 if (is_initialized(m)) {
3421 msegmentptr s = &m->seg;
3422 sum += m->topsize + TOP_FOOT_SIZE;
3423 while (s != 0) {
3424 mchunkptr q = align_as_chunk(s->base);
3425 mchunkptr lastq = 0;
3426 assert(pinuse(q));
3427 while (segment_holds(s, q) &&
3428 q != m->top && q->head != FENCEPOST_HEAD) {
3429 sum += chunksize(q);
3430 if (is_inuse(q)) {
3431 assert(!bin_find(m, q));
3432 do_check_inuse_chunk(m, q);
3433 }
3434 else {
3435 assert(q == m->dv || bin_find(m, q));
3436 assert(lastq == 0 || is_inuse(lastq)); /* Not 2 consecutive free */
3437 do_check_free_chunk(m, q);
3438 }
3439 lastq = q;
3440 q = next_chunk(q);
3441 }
3442 s = s->next;
3443 }
3444 }
3445 return sum;
3446}
3447
3448
3449/* Check all properties of malloc_state. */

Callers 1

do_check_malloc_stateFunction · 0.85

Calls 3

bin_findFunction · 0.85
do_check_inuse_chunkFunction · 0.85
do_check_free_chunkFunction · 0.85

Tested by

no test coverage detected