DebugAllocatorLiveBytes
Description
Total user-requested bytes still outstanding, summed by the allocate / deallocate hooks into bytes_in_use.
Parameters
| Name | Direction | Description |
|---|---|---|
self |
in | DebugAllocator instance, or NULL. |
Success
Returns the outstanding-bytes count. No state is touched.
Failure
Returns 0 when self is NULL.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Debug.c:511:
}
size DebugAllocatorLiveBytes(const DebugAllocator *self) {
if (!self)
return 0;- In
AllocDebug.c:38:
bool ok = p1 && p2;
ok = ok && DebugAllocatorLiveCount(&dbg) == 2;
ok = ok && DebugAllocatorLiveBytes(&dbg) == (64 + 128);
AllocatorFree(adbg, p1);- In
AllocDebug.c:42:
AllocatorFree(adbg, p1);
ok = ok && DebugAllocatorLiveCount(&dbg) == 1;
ok = ok && DebugAllocatorLiveBytes(&dbg) == 128;
AllocatorFree(adbg, p2);- In
AllocDebug.c:46:
AllocatorFree(adbg, p2);
ok = ok && DebugAllocatorLiveCount(&dbg) == 0;
ok = ok && DebugAllocatorLiveBytes(&dbg) == 0;
ok = ok && DebugAllocatorOverflows(&dbg) == 0;- In
AllocDebug.c:105:
bool ok = DebugAllocatorLiveCount(&dbg) == 2;
ok = ok && DebugAllocatorLiveBytes(&dbg) == (32 + 48);
DebugAllocatorDeinit(&dbg); // logs the leaks
- In
AllocDebug.c:236:
ok = ok && (grown != NULL) && (grown[0] == 'h') && (grown[15] == '!');
ok = ok && (DebugAllocatorLiveCount(&dbg) == 1);
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 200);
if (grown)- In
AllocDebug.c:281:
void *p = AllocatorAlloc(adbg, 64, true);
bool ok = (p != NULL) && (DebugAllocatorLiveCount(&dbg) == 1);
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 64);
ok = ok && (((u64)p & 0xfff) == 0); // page-aligned
- In
AllocDebug.c:617:
// self->bytes_in_use is surfaced by DebugAllocatorLiveBytes. A
// mutated `-=` underflows to a huge u64 instead of 100.
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 100);
if (p)- In
AllocDebug.c:621:
if (p)
AllocatorFree(adbg, p);
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);
return ok;- In
AllocDebug.c:763:
// No live record / bytes for a failed alloc.
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0);
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);- In
AllocDebug.c:934:
}
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0);
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);- In
AllocDebug.c:954:
// The allocation is untouched -- still one live record of 64 bytes.
ok = ok && (DebugAllocatorLiveCount(&dbg) == 1);
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 64);
if (p) ok = ok && (grown[63] == 0x6B);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 1);
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 200);
if (grown) ok = ok && (shrunk[i] == (u8)(i + 1));
ok = ok && (DebugAllocatorLiveCount(&dbg) == 1);
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 8);
if (shrunk)- In
Init.c:13:
// A test passes iff `ok` held AND the DebugAllocator has no outstanding
// allocations after the test released everything it owns.
#define LEAK_CLEAN(dbg) (DebugAllocatorLiveCount(&(dbg)) == 0 && DebugAllocatorLiveBytes(&(dbg)) == 0)
static bool test_graph_reserve_clear(void) {- In
Compare.c:13:
// Convenience: a test passes iff `ok` held AND the DebugAllocator has no
// outstanding allocations after the test released everything it owns.
#define LEAK_CLEAN(dbg) (DebugAllocatorLiveCount(&(dbg)) == 0 && DebugAllocatorLiveBytes(&(dbg)) == 0)
// Leak-only config: live-count tracking, NO per-alloc stack-trace / canary /
- In
Math.c:13:
// Convenience: a test passes iff `ok` held AND the DebugAllocator has no
// outstanding allocations after the test released everything it owns.
#define LEAK_CLEAN(dbg) (DebugAllocatorLiveCount(&(dbg)) == 0 && DebugAllocatorLiveBytes(&(dbg)) == 0)
// Leak-only config: live-count tracking, NO per-alloc stack-trace / canary /
- In
Convert.c:13:
// Convenience: a test passes iff `ok` held AND the DebugAllocator has no
// outstanding allocations after the test released everything it owns.
#define LEAK_CLEAN(dbg) (DebugAllocatorLiveCount(&(dbg)) == 0 && DebugAllocatorLiveBytes(&(dbg)) == 0)
// Leak-only config: live-count tracking, NO per-alloc stack-trace / canary /
- In
Math.c:14:
}
#define LEAK_CLEAN(dbg) (DebugAllocatorLiveCount(&(dbg)) == 0 && DebugAllocatorLiveBytes(&(dbg)) == 0)
#define LEAK_CFG \- In
Convert.c:15:
}
#define LEAK_CLEAN(dbg) (DebugAllocatorLiveCount(&(dbg)) == 0 && DebugAllocatorLiveBytes(&(dbg)) == 0)
#define LEAK_CFG \- In
Write.c:4784:
#define LEAK_WRITE_EPILOGUE() \
StrDeinit(&out); \
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0) && (DebugAllocatorLiveBytes(&dbg) == 0); \
DebugAllocatorDeinit(&dbg); \
return ok- In
Write.c:5475:
bool ok = StrAppendFmt(&out, "{x}", s) && (StrLen(&out) > 0);
StrDeinit(&out);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0) && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);
StrDeinit(&s);- In
Write.c:5496:
ok = ok && StrAppendFmt(&out, "{}", f) && (StrLen(&out) > 0);
StrDeinit(&out);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0) && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);
FloatDeinit(&f);- In
Write.c:5525:
StrDeinit(&out);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0);
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 0);
FloatDeinit(&v);- In
Write.c:5551:
StrDeinit(&out);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0);
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 0);
FloatDeinit(&v);- In
Write.c:5577:
StrDeinit(&out);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0);
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 0);
FloatDeinit(&v);- In
Write.c:5604:
StrDeinit(&out);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0);
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 0);
FloatDeinit(&v);- In
Write.c:5631:
StrDeinit(&out);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0);
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);- In
Write.c:5655:
StrDeinit(&out);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0);
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);- In
Write.c:5680:
ok = ok && StrAppendFmt(&out, "{}", s) && (StrLen(&out) > 0);
StrDeinit(&out);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0) && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);
StrDeinit(&s);- In
Write.c:5693:
ok = ok && StrAppendFmt(&out, "{}", v) && (StrLen(&out) > 0);
StrDeinit(&out);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0) && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);
IntDeinit(&v);- In
Write.c:5706:
ok = ok && StrAppendFmt(&out, "{}", v) && (StrLen(&out) > 0);
StrDeinit(&out);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0) && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);
FloatDeinit(&v);- In
Write.c:5720:
ok = ok && StrAppendFmt(&out, "{}", v) && (StrLen(&out) > 0);
StrDeinit(&out);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0) && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);
BitVecDeinit(&v);- In
Read.c:2734:
Zstr p = input;
StrReadFmt(p, fmt, s); // reader frees s on the unterminated/error branch
bool ok = (DebugAllocatorLiveCount(&dbg) == 0) && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);
return ok;- In
Read.c:2747:
StrReadFmt(p, "{}", bv);
BitVecDeinit(&bv);
bool ok = (DebugAllocatorLiveCount(&dbg) == 0) && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);
return ok;- In
Read.c:2774:
Zstr p = "aaaaaaaaaaaaaaaaaaaaaaaa\\q"; // 24 'a' + invalid \q
StrReadFmt(p, "{}", s);
bool ok = (DebugAllocatorLiveCount(&dbg) == 0) && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);
return ok;- In
Read.c:2795:
StrReadFmt(p, "{}", fv);
FloatDeinit(&fv);
bool ok = (DebugAllocatorLiveCount(&dbg) == 0) && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);
return ok;- In
Read.c:2830:
IntDeinit(&value);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0);
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);- In
Read.c:2857:
FloatDeinit(&value);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0);
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);- In
Dns.c:2091:
DnsResponseDeinit(&resp);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0);
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);- In
Dns.c:2159:
DnsResponseDeinit(&resp);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0);
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);- In
Dns.c:2187:
DnsResponseDeinit(&resp);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0);
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);- In
Parse.c:718:
// The stripped-away old value buffer must already be freed.
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0);
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);- In
Parse.c:749:
// The parser's local key copy must already be freed.
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0);
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);- In
Parse.c:779:
// The parser's local value copy must already be freed.
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0);
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);- In
Parse.c:820:
// Every transient lookup key must already be freed.
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0);
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);
Last updated on