summaryrefslogtreecommitdiffstats
path: root/mysys/safemalloc.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--mysys/safemalloc.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/mysys/safemalloc.c b/mysys/safemalloc.c
index edfe3b18..2fc34a92 100644
--- a/mysys/safemalloc.c
+++ b/mysys/safemalloc.c
@@ -70,7 +70,7 @@ struct st_irem
uint32 marker; /* Underrun marker value */
};
-static int sf_malloc_count= 0; /* Number of allocated chunks */
+static uint sf_malloc_count= 0; /* Number of allocated chunks */
static void *sf_min_adress= (void*) (intptr)~0ULL,
*sf_max_adress= 0;
@@ -362,7 +362,7 @@ int sf_sanity()
{
struct st_irem *irem;
int flag= 0;
- int count= 0;
+ uint count= 0;
pthread_mutex_lock(&sf_mutex);
count= sf_malloc_count;
@@ -387,6 +387,7 @@ void sf_report_leaked_memory(my_thread_id id)
{
size_t total= 0;
struct st_irem *irem;
+ uint first= 0, chunks= 0;
sf_sanity();
@@ -398,15 +399,18 @@ void sf_report_leaked_memory(my_thread_id id)
{
my_thread_id tid = irem->thread_id && irem->flags & MY_THREAD_SPECIFIC ?
irem->thread_id : 0;
+ if (!first++)
+ fprintf(stderr, "Memory report from safemalloc\n");
fprintf(stderr, "Warning: %4lu bytes lost at %p, allocated by T@%llu at ",
(ulong) irem->datasize, (char*) (irem + 1), tid);
print_stack(irem->frame);
total+= irem->datasize;
+ chunks++;
}
}
if (total)
- fprintf(stderr, "Memory lost: %lu bytes in %d chunks\n",
- (ulong) total, sf_malloc_count);
+ fprintf(stderr, "Memory lost: %lu bytes in %u chunks of %u total chunks\n",
+ (ulong) total, chunks, sf_malloc_count);
return;
}