MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / do_check_smallbin

Function do_check_smallbin

dlmalloc/dlmalloc.c:2746–2767  ·  view source on GitHub ↗

Check all the chunks in a smallbin. */

Source from the content-addressed store, hash-verified

2744
2745/* Check all the chunks in a smallbin. */
2746static void do_check_smallbin(mstate m, bindex_t i) {
2747 sbinptr b = smallbin_at(m, i);
2748 mchunkptr p = b->bk;
2749 unsigned int empty = (m->smallmap & (1U << i)) == 0;
2750 if (p == b)
2751 assert(empty);
2752 if (!empty) {
2753 for (; p != b; p = p->bk) {
2754 size_t size = chunksize(p);
2755 mchunkptr q;
2756 /* each chunk claims to be free */
2757 do_check_free_chunk(m, p);
2758 /* chunk belongs in bin */
2759 assert(small_index(size) == i);
2760 assert(p->bk == b || chunksize(p->bk) == chunksize(p));
2761 /* chunk is followed by an inuse chunk */
2762 q = next_chunk(p);
2763 if (q->head != FENCEPOST_HEAD)
2764 do_check_inuse_chunk(m, q);
2765 }
2766 }
2767}
2768
2769/* Find x in a bin. Used in other check functions. */
2770static int bin_find(mstate m, mchunkptr x) {

Callers 1

do_check_malloc_stateFunction · 0.85

Calls 2

do_check_free_chunkFunction · 0.85
do_check_inuse_chunkFunction · 0.85

Tested by

no test coverage detected