diff options
author | Haru <haru@dotalux.com> | 2014-07-10 11:21:36 +0200 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2014-07-10 11:21:36 +0200 |
commit | 3c24fb656f3b3370b7152d6f1d2cc9dbc6fbae5d (patch) | |
tree | 025ea42b2bfa0204138427e5c69a074912fc435b /src/common | |
parent | 8e3b160fa7f62246fd19bb973f544b387d42eeb2 (diff) | |
download | hercules-3c24fb656f3b3370b7152d6f1d2cc9dbc6fbae5d.tar.gz hercules-3c24fb656f3b3370b7152d6f1d2cc9dbc6fbae5d.tar.bz2 hercules-3c24fb656f3b3370b7152d6f1d2cc9dbc6fbae5d.tar.xz hercules-3c24fb656f3b3370b7152d6f1d2cc9dbc6fbae5d.zip |
Re-added revision info to the memory leak log
- Information was missing because sysinfo->final() was freeing the data
before iMalloc->final() could log it.
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/core.c | 2 | ||||
-rw-r--r-- | src/common/malloc.c | 14 |
2 files changed, 9 insertions, 7 deletions
diff --git a/src/common/core.c b/src/common/core.c index d74e5a451..28c84e2cf 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -267,7 +267,7 @@ int main (int argc, char **argv) { rathread_final(); ers_final(); #endif - sysinfo->final(); + //sysinfo->final(); Called by iMalloc->final() iMalloc->final(); diff --git a/src/common/malloc.c b/src/common/malloc.c index 83d1d6656..f164c6660 100644 --- a/src/common/malloc.c +++ b/src/common/malloc.c @@ -573,8 +573,7 @@ size_t memmgr_usage (void) static char memmer_logfile[128]; static FILE *log_fp; -static void memmgr_log (char *buf) -{ +static void memmgr_log(char *buf, char *vcsinfo) { if( !log_fp ) { time_t raw; struct tm* t; @@ -584,8 +583,8 @@ static void memmgr_log (char *buf) time(&raw); t = localtime(&raw); - fprintf(log_fp, "\nMemory manager: Memory leaks found at %d/%02d/%02d %02dh%02dm%02ds (%s rev '%s').\n", - (t->tm_year+1900), (t->tm_mon+1), t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, sysinfo->vcstype(), sysinfo->vcsrevision_src()); + fprintf(log_fp, "\nMemory manager: Memory leaks found at %d/%02d/%02d %02dh%02dm%02ds (%s).\n", + (t->tm_year+1900), (t->tm_mon+1), t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, vcsinfo); } fprintf(log_fp, "%s", buf); return; @@ -642,6 +641,9 @@ static void memmgr_final (void) { struct block *block = block_first; struct unit_head_large *large = unit_head_large_first; + char vcsinfo[256]; + snprintf(vcsinfo, sizeof(vcsinfo), "%s rev '%s'", sysinfo->vcstype(), sysinfo->vcsrevision_src()); // Cache VCS info before we free() it + sysinfo->final(); #ifdef LOG_MEMMGR int count = 0; @@ -659,7 +661,7 @@ static void memmgr_final (void) sprintf (buf, "%04d : %s line %d size %lu address 0x%p\n", ++count, head->file, head->line, (unsigned long)head->size, ptr); - memmgr_log (buf); + memmgr_log(buf, vcsinfo); #endif /* LOG_MEMMGR */ // get block pointer and free it [celest] iMalloc->free(ptr, ALC_MARK); @@ -676,7 +678,7 @@ static void memmgr_final (void) sprintf (buf, "%04d : %s line %d size %lu address 0x%p\n", ++count, large->unit_head.file, large->unit_head.line, (unsigned long)large->size, &large->unit_head.checksum); - memmgr_log (buf); + memmgr_log(buf, vcsinfo); #endif /* LOG_MEMMGR */ large2 = large->next; FREE(large,file,line,func); |