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);
|
enumerator = entries->create_enumerator(entries);
|
||||||
while (enumerator->enumerate(enumerator, NULL, &entry))
|
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",
|
fprintf(out, "%d bytes total, %d allocations, %d bytes average:\n",
|
||||||
entry->bytes, entry->count, entry->bytes / entry->count);
|
entry->bytes, entry->count, entry->bytes / entry->count);
|
||||||
@@ -609,7 +609,7 @@ METHOD(leak_detective_t, report, void,
|
|||||||
{
|
{
|
||||||
if (lib->leak_detective)
|
if (lib->leak_detective)
|
||||||
{
|
{
|
||||||
int leaks = 0, whitelisted = 0;
|
int leaks, whitelisted = 0;
|
||||||
|
|
||||||
leaks = print_traces(this, stderr, 0, detailed, &whitelisted);
|
leaks = print_traces(this, stderr, 0, detailed, &whitelisted);
|
||||||
switch (leaks)
|
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,
|
METHOD(leak_detective_t, set_state, bool,
|
||||||
private_leak_detective_t *this, bool enable)
|
private_leak_detective_t *this, bool enable)
|
||||||
{
|
{
|
||||||
@@ -885,6 +898,7 @@ leak_detective_t *leak_detective_create()
|
|||||||
INIT(this,
|
INIT(this,
|
||||||
.public = {
|
.public = {
|
||||||
.report = _report,
|
.report = _report,
|
||||||
|
.leaks = _leaks,
|
||||||
.usage = _usage,
|
.usage = _usage,
|
||||||
.set_state = _set_state,
|
.set_state = _set_state,
|
||||||
.destroy = _destroy,
|
.destroy = _destroy,
|
||||||
|
|||||||
@@ -42,6 +42,13 @@ struct leak_detective_t {
|
|||||||
*/
|
*/
|
||||||
void (*report)(leak_detective_t *this, bool detailed);
|
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.
|
* Report current memory usage to out.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user