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

Function internal_mallinfo

system/lib/dlmalloc.c:3568–3605  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3566
3567#if !NO_MALLINFO
3568static struct mallinfo internal_mallinfo(mstate m) {
3569 struct mallinfo nm = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
3570 ensure_initialization();
3571 if (!PREACTION(m)) {
3572 check_malloc_state(m);
3573 if (is_initialized(m)) {
3574 size_t nfree = SIZE_T_ONE; /* top always free */
3575 size_t mfree = m->topsize + TOP_FOOT_SIZE;
3576 size_t sum = mfree;
3577 msegmentptr s = &m->seg;
3578 while (s != 0) {
3579 mchunkptr q = align_as_chunk(s->base);
3580 while (segment_holds(s, q) &&
3581 q != m->top && q->head != FENCEPOST_HEAD) {
3582 size_t sz = chunksize(q);
3583 sum += sz;
3584 if (!is_inuse(q)) {
3585 mfree += sz;
3586 ++nfree;
3587 }
3588 q = next_chunk(q);
3589 }
3590 s = s->next;
3591 }
3592
3593 nm.arena = sum;
3594 nm.ordblks = nfree;
3595 nm.hblkhd = m->footprint - sum;
3596 nm.usmblks = m->max_footprint;
3597 nm.uordblks = m->footprint - mfree;
3598 nm.fordblks = mfree;
3599 nm.keepcost = m->topsize;
3600 }
3601
3602 POSTACTION(m);
3603 }
3604 return nm;
3605}
3606#endif /* !NO_MALLINFO */
3607
3608#if !NO_MALLOC_STATS

Callers 2

dlmallinfoFunction · 0.85
mspace_mallinfoFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected