From: Elliott Hughes Date: Wed, 30 Jan 2013 19:38:26 +0000 (-0800) Subject: Say explicitly if there were no leaks. X-Git-Tag: android-x86-4.4-r1~313^2~25^2~28^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=1d12d574169cedd68185196e4957597d00fd4681;p=android-x86%2Fbionic.git 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 --- diff --git a/libc/bionic/malloc_debug_check.cpp b/libc/bionic/malloc_debug_check.cpp index 18c3ed4c3..394b8bb0f 100644 --- a/libc/bionic/malloc_debug_check.cpp +++ b/libc/bionic/malloc_debug_check.cpp @@ -437,10 +437,6 @@ extern "C" void *chk_calloc(int nmemb, size_t size) { } static void heaptracker_free_leaked_memory() { - if (gAllocatedBlockCount == 0) { - return; - } - // Use /proc/self/exe link to obtain the program name for logging // purposes. If it's not available, we set it to "". char exe[PATH_MAX]; @@ -451,6 +447,11 @@ static void heaptracker_free_leaked_memory() { exe[count] = '\0'; } + if (gAllocatedBlockCount == 0) { + log_message("+++ %s did not leak", exe); + return; + } + size_t index = 1; const size_t total = gAllocatedBlockCount; while (head != NULL) {