Reports the size of the allocated memory.

This commit is contained in:
Andrea Mazzoleni 2011-12-31 12:37:47 +01:00
parent a0ad57d4f1
commit 4e2cb40f98
3 changed files with 16 additions and 0 deletions

9
util.c
View file

@ -643,6 +643,13 @@ void pathslash(char* dst, size_t size)
/****************************************************************************/
/* mem */
static size_t mcounter;
size_t malloc_counter(void)
{
return mcounter;
}
void* malloc_nofail(size_t size)
{
void* ptr = malloc(size);
@ -652,6 +659,8 @@ void* malloc_nofail(size_t size)
exit(EXIT_FAILURE);
}
mcounter += size;
return ptr;
}