Keep track of number of time free called

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2050 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2009-09-13 22:35:04 +00:00
parent 6e2d6f7833
commit 166b171d43

View File

@ -67,6 +67,7 @@
#ifdef CONFIG_THTTPD_MEMDEBUG
static int g_nallocations = 0;
static int g_nfreed = 0;
static size_t g_allocated = 0;
#endif
@ -81,7 +82,7 @@ void httpd_memstats(void)
{
static struct mallinfo mm;
ndbg("%d allocations (%lu bytes)\n", g_nallocations, (unsigned long)g_allocated);
ndbg("%d allocations (%lu bytes), %d freed\n", g_nallocations, (unsigned long)g_allocated, g_nfreed);
/* Get the current memory usage */
@ -142,6 +143,7 @@ FAR void *httpd_realloc(FAR void *oldptr, size_t oldsize, size_t newsize)
void httpd_free(FAR void *ptr)
{
free(ptr);
g_nfreed++;
nvdbg("Freed memory at %p\n", ptr);
httpd_memstats();
}