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

Function do_check_smallbin

system/lib/dlmalloc.c:3444–3465  ·  view source on GitHub ↗

Check all the chunks in a smallbin. */

Source from the content-addressed store, hash-verified

3442
3443/* Check all the chunks in a smallbin. */
3444static void do_check_smallbin(mstate m, bindex_t i) {
3445 sbinptr b = smallbin_at(m, i);
3446 mchunkptr p = b->bk;
3447 unsigned int empty = (m->smallmap & (1U << i)) == 0;
3448 if (p == b)
3449 assert(empty);
3450 if (!empty) {
3451 for (; p != b; p = p->bk) {
3452 size_t size = chunksize(p);
3453 mchunkptr q;
3454 /* each chunk claims to be free */
3455 do_check_free_chunk(m, p);
3456 /* chunk belongs in bin */
3457 assert(small_index(size) == i);
3458 assert(p->bk == b || chunksize(p->bk) == chunksize(p));
3459 /* chunk is followed by an inuse chunk */
3460 q = next_chunk(p);
3461 if (q->head != FENCEPOST_HEAD)
3462 do_check_inuse_chunk(m, q);
3463 }
3464 }
3465}
3466
3467/* Find x in a bin. Used in other check functions. */
3468static int bin_find(mstate m, mchunkptr x) {

Callers 1

do_check_malloc_stateFunction · 0.85

Calls 3

do_check_free_chunkFunction · 0.85
do_check_inuse_chunkFunction · 0.85
assertFunction · 0.50

Tested by

no test coverage detected