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

Function internal_inspect_all

system/lib/dlmalloc.c:5235–5272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5233/* Traversal */
5234#if MALLOC_INSPECT_ALL
5235static void internal_inspect_all(mstate m,
5236 void(*handler)(void *start,
5237 void *end,
5238 size_t used_bytes,
5239 void* callback_arg),
5240 void* arg) {
5241 if (is_initialized(m)) {
5242 mchunkptr top = m->top;
5243 msegmentptr s;
5244 for (s = &m->seg; s != 0; s = s->next) {
5245 mchunkptr q = align_as_chunk(s->base);
5246 while (segment_holds(s, q) && q->head != FENCEPOST_HEAD) {
5247 mchunkptr next = next_chunk(q);
5248 size_t sz = chunksize(q);
5249 size_t used;
5250 void* start;
5251 if (is_inuse(q)) {
5252 used = sz - CHUNK_OVERHEAD; /* must not be mmapped */
5253 start = chunk2mem(q);
5254 }
5255 else {
5256 used = 0;
5257 if (is_small(sz)) { /* offset by possible bookkeeping */
5258 start = (void*)((char*)q + sizeof(struct malloc_chunk));
5259 }
5260 else {
5261 start = (void*)((char*)q + sizeof(struct malloc_tree_chunk));
5262 }
5263 }
5264 if (start < (void*)next) /* skip if all space is bookkeeping */
5265 handler(start, next, used, arg);
5266 if (q == top)
5267 break;
5268 q = next;
5269 }
5270 }
5271 }
5272}
5273#endif /* MALLOC_INSPECT_ALL */
5274
5275/* ------------------ Exported realloc, memalign, etc -------------------- */

Callers 2

dlmalloc_inspect_allFunction · 0.85
mspace_inspect_allFunction · 0.85

Calls 1

handlerFunction · 0.85

Tested by

no test coverage detected