Say explicitly if there were no leaks.

Otherwise people trying to use this are left wondering "did I not leak, or did
the leak checking code not get called when I exited?".

Change-Id: If79b225f8a2e24dd69aba1fb836bf9e81bb00efe
This commit is contained in:
Elliott Hughes 2013-01-30 11:38:26 -08:00
parent a990cf5b33
commit 1d12d57416

View File

@ -437,10 +437,6 @@ extern "C" void *chk_calloc(int nmemb, size_t size) {
} }
static void heaptracker_free_leaked_memory() { static void heaptracker_free_leaked_memory() {
if (gAllocatedBlockCount == 0) {
return;
}
// Use /proc/self/exe link to obtain the program name for logging // Use /proc/self/exe link to obtain the program name for logging
// purposes. If it's not available, we set it to "<unknown>". // purposes. If it's not available, we set it to "<unknown>".
char exe[PATH_MAX]; char exe[PATH_MAX];
@ -451,6 +447,11 @@ static void heaptracker_free_leaked_memory() {
exe[count] = '\0'; exe[count] = '\0';
} }
if (gAllocatedBlockCount == 0) {
log_message("+++ %s did not leak", exe);
return;
}
size_t index = 1; size_t index = 1;
const size_t total = gAllocatedBlockCount; const size_t total = gAllocatedBlockCount;
while (head != NULL) { while (head != NULL) {