enumerator = entries->create_enumerator(entries);
while (enumerator->enumerate(enumerator, NULL, &entry))
{
- if (!thresh || entry->bytes >= thresh)
+ if (out && (!thresh || entry->bytes >= thresh))
{
fprintf(out, "%d bytes total, %d allocations, %d bytes average:\n",
entry->bytes, entry->count, entry->bytes / entry->count);
{
if (lib->leak_detective)
{
- int leaks = 0, whitelisted = 0;
+ int leaks, whitelisted = 0;
leaks = print_traces(this, stderr, 0, detailed, &whitelisted);
switch (leaks)
}
}
+METHOD(leak_detective_t, leaks, int,
+ private_leak_detective_t *this)
+{
+ if (lib->leak_detective)
+ {
+ int leaks, whitelisted = 0;
+
+ leaks = print_traces(this, NULL, 0, FALSE, &whitelisted);
+ return leaks;
+ }
+ return 0;
+}
+
METHOD(leak_detective_t, set_state, bool,
private_leak_detective_t *this, bool enable)
{
INIT(this,
.public = {
.report = _report,
+ .leaks = _leaks,
.usage = _usage,
.set_state = _set_state,
.destroy = _destroy,
void (*report)(leak_detective_t *this, bool detailed);
/**
+ * Number of detected leaks.
+ *
+ * @return number of leaks
+ */
+ int (*leaks)(leak_detective_t *this);
+
+ /**
* Report current memory usage to out.
*
* @param out target to write usage report to