Add getter for the number of leaks to leak_detective_t
This commit is contained in:
@@ -589,7 +589,7 @@ static int print_traces(private_leak_detective_t *this,
|
||||
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);
|
||||
@@ -609,7 +609,7 @@ METHOD(leak_detective_t, report, void,
|
||||
{
|
||||
if (lib->leak_detective)
|
||||
{
|
||||
int leaks = 0, whitelisted = 0;
|
||||
int leaks, whitelisted = 0;
|
||||
|
||||
leaks = print_traces(this, stderr, 0, detailed, &whitelisted);
|
||||
switch (leaks)
|
||||
@@ -632,6 +632,19 @@ METHOD(leak_detective_t, report, void,
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -885,6 +898,7 @@ leak_detective_t *leak_detective_create()
|
||||
INIT(this,
|
||||
.public = {
|
||||
.report = _report,
|
||||
.leaks = _leaks,
|
||||
.usage = _usage,
|
||||
.set_state = _set_state,
|
||||
.destroy = _destroy,
|
||||
|
||||
@@ -42,6 +42,13 @@ struct leak_detective_t {
|
||||
*/
|
||||
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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user