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
Float.Leak.c:25:
// 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
Dns.Leak.c:54:
DnsResponseDeinit(&resp);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0);
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);- In
Dns.Leak.c:122:
DnsResponseDeinit(&resp);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0);
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);- In
Dns.Leak.c:150:
DnsResponseDeinit(&resp);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0);
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);- 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
Graph.Leak.c:22:
// 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)
typedef Graph(int) IntGraph;- In
Int.Leak.c:20:
#include "../Util/TestRunner.h"
#define LEAK_CLEAN(dbg) (DebugAllocatorLiveCount(&(dbg)) == 0 && DebugAllocatorLiveBytes(&(dbg)) == 0)
// Leak-only config: live-count tracking with NO per-alloc stack-trace capture,
- In
Io.Leak.c:66:
StrDeinit(&out);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0);
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 0);
FloatDeinit(&v);- In
Io.Leak.c:92:
StrDeinit(&out);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0);
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 0);
FloatDeinit(&v);- In
Io.Leak.c:118:
StrDeinit(&out);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0);
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 0);
FloatDeinit(&v);- In
Io.Leak.c:145:
StrDeinit(&out);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0);
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 0);
FloatDeinit(&v);- In
Io.Leak.c:183:
IntDeinit(&value);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0);
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);- In
Io.Leak.c:210:
FloatDeinit(&value);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0);
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);- In
Io.Leak.c:235:
StrDeinit(&out);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0);
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);- In
Io.Leak.c:259:
StrDeinit(&out);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0);
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);- In
Io.Leak.c:280:
#define LEAK_WRITE_EPILOGUE() \
StrDeinit(&out); \
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0) && (DebugAllocatorLiveBytes(&dbg) == 0); \
DebugAllocatorDeinit(&dbg); \
return ok- In
Io.Leak.c:303:
ok = ok && StrAppendFmt(&out, "{}", s) && (StrLen(&out) > 0);
StrDeinit(&out);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0) && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);
StrDeinit(&s);- In
Io.Leak.c:316:
ok = ok && StrAppendFmt(&out, "{}", v) && (StrLen(&out) > 0);
StrDeinit(&out);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0) && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);
IntDeinit(&v);- In
Io.Leak.c:329:
ok = ok && StrAppendFmt(&out, "{}", v) && (StrLen(&out) > 0);
StrDeinit(&out);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0) && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);
FloatDeinit(&v);- In
Io.Leak.c:343:
ok = ok && StrAppendFmt(&out, "{}", v) && (StrLen(&out) > 0);
StrDeinit(&out);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0) && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);
BitVecDeinit(&v);- In
Io.Leak.c:366:
bool ok = StrAppendFmt(&out, "{x}", s) && (StrLen(&out) > 0);
StrDeinit(&out);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0) && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);
StrDeinit(&s);- In
Io.Leak.c:387:
ok = ok && StrAppendFmt(&out, "{}", f) && (StrLen(&out) > 0);
StrDeinit(&out);
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0) && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);
FloatDeinit(&f);- In
Io.Leak.c:408:
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
Io.Leak.c:435:
Zstr p = "aaaaaaaaaaaaaaaaaaaaaaaa\\q"; // 24 'a' + invalid \q
StrReadFmt(p, "{}", s);
bool ok = (DebugAllocatorLiveCount(&dbg) == 0) && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);
return ok;- In
Io.Leak.c:448:
StrReadFmt(p, "{}", bv);
BitVecDeinit(&bv);
bool ok = (DebugAllocatorLiveCount(&dbg) == 0) && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);
return ok;- In
Io.Leak.c:469:
StrReadFmt(p, "{}", fv);
FloatDeinit(&fv);
bool ok = (DebugAllocatorLiveCount(&dbg) == 0) && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);
return ok;- In
Leak.c:52:
// The stripped-away old value buffer must already be freed.
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0);
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);- In
Leak.c:85:
// The parser's local key copy must already be freed.
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0);
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);- In
Leak.c:117:
// The parser's local value copy must already be freed.
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0);
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);- In
Leak.c:160:
// Every transient lookup key must already be freed.
ok = ok && (DebugAllocatorLiveCount(&dbg) == 0);
ok = ok && (DebugAllocatorLiveBytes(&dbg) == 0);
DebugAllocatorDeinit(&dbg);
Last updated on