Module <cweb/leak_detector.h> — allocation tracking (debug)
Optional leak tracker for development and testing; can work together with framework-internal malloc hooks.
Functions
void cweb_leak_tracker_record(const char *name, const void *pointer, size_t size, bool is_allocation)
- Purpose: Reports an allocation (
is_allocation == true) or release (false) forpointer. - Parameters:
name— human-readable label (may beNULL).pointer— address.size— size in bytes on allocation (on release ignored or used for validation depending on implementation).is_allocation— allocation vs. deallocation.
void cweb_leak_tracker_dump(void)
- Purpose: Prints a report of allocations still being tracked via the logger (typically before process exit).
size_t cweb_leak_tracker_outstanding(void)
- Purpose: Number of pointers currently tracked.
void cweb_leak_tracker_reset(void)
- Purpose: Clears the tracking table without a report (mainly for tests).
Notes
- In production, usually disable or minimize overhead.
- If at least one allocation was registered, a report may run automatically on exit (header comment).