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

Function bin_find

lib/dlmalloc/malloc.c:3382–3415  ·  view source on GitHub ↗

Find x in a bin. Used in other check functions. */

Source from the content-addressed store, hash-verified

3380
3381/* Find x in a bin. Used in other check functions. */
3382static int bin_find(mstate m, mchunkptr x) {
3383 size_t size = chunksize(x);
3384 if (is_small(size)) {
3385 bindex_t sidx = small_index(size);
3386 sbinptr b = smallbin_at(m, sidx);
3387 if (smallmap_is_marked(m, sidx)) {
3388 mchunkptr p = b;
3389 do {
3390 if (p == x)
3391 return 1;
3392 } while ((p = p->fd) != b);
3393 }
3394 }
3395 else {
3396 bindex_t tidx;
3397 compute_tree_index(size, tidx);
3398 if (treemap_is_marked(m, tidx)) {
3399 tchunkptr t = *treebin_at(m, tidx);
3400 size_t sizebits = size << leftshift_for_tree_index(tidx);
3401 while (t != 0 && chunksize(t) != size) {
3402 t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1];
3403 sizebits <<= 1;
3404 }
3405 if (t != 0) {
3406 tchunkptr u = t;
3407 do {
3408 if (u == (tchunkptr)x)
3409 return 1;
3410 } while ((u = u->fd) != t);
3411 }
3412 }
3413 }
3414 return 0;
3415}
3416
3417/* Traverse each chunk and check it; return total */
3418static size_t traverse_and_check(mstate m) {

Callers 2

traverse_and_checkFunction · 0.85
do_check_malloc_stateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected