From: <mar...@us...> - 2010-06-23 14:09:11
|
Revision: 3387 http://navit.svn.sourceforge.net/navit/?rev=3387&view=rev Author: martin-s Date: 2010-06-23 14:09:05 +0000 (Wed, 23 Jun 2010) Log Message: ----------- Add:Core:Better support for debugging memory leaks Modified Paths: -------------- trunk/navit/navit/debug.c Modified: trunk/navit/navit/debug.c =================================================================== --- trunk/navit/navit/debug.c 2010-06-23 13:06:57 UTC (rev 3386) +++ trunk/navit/navit/debug.c 2010-06-23 14:09:05 UTC (rev 3387) @@ -246,7 +246,7 @@ int magic; }; -int mallocs; +int mallocs,malloc_size,malloc_size_m; void debug_dump_mallocs(void) @@ -273,6 +273,11 @@ if (!size) return NULL; mallocs++; + malloc_size+=size; + if (malloc_size/(1024*1024) != malloc_size_m) { + malloc_size_m=malloc_size/(1024*1024); + dbg(0,"malloced %d kb\n",malloc_size/1024); + } head=malloc(size+sizeof(*head)+sizeof(*tail)); head->magic=0xdeadbeef; head->size=size; @@ -347,6 +352,7 @@ mallocs--; head=(struct malloc_head *)((unsigned char *)ptr-sizeof(*head)); tail=(struct malloc_tail *)((unsigned char *)ptr+head->size); + malloc_size-=head->size; if (head->magic != 0xdeadbeef || tail->magic != 0xdeadbef0) { fprintf(stderr,"Invalid free from %s:%d %s\n",where,line,func); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |