add a calloc to mempool

This commit is contained in:
eehouse 2010-01-02 01:42:07 +00:00
parent b5e1e3a2c6
commit c7729ca25c
2 changed files with 11 additions and 0 deletions

View file

@ -178,6 +178,8 @@ typedef struct CommonPrefs {
#ifdef MEM_DEBUG
# define XP_MALLOC(pool,nbytes) \
mpool_alloc((pool),(nbytes),__FILE__,__func__, __LINE__)
# define XP_CALLOC(pool,nbytes) \
mpool_calloc((pool),(nbytes),__FILE__,__func__, __LINE__)
# define XP_REALLOC(pool,p,s) \
mpool_realloc((pool),(p),(s),__FILE__,__func__,__LINE__)
# define XP_FREE(pool,p) \

View file

@ -161,6 +161,15 @@ mpool_alloc( MemPoolCtx* mpool, XP_U32 size, const char* file,
return entry->ptr;
} /* mpool_alloc */
void*
mpool_calloc( MemPoolCtx* mpool, XP_U32 size, const char* file,
const char* func, XP_U32 lineNo )
{
void* ptr = mpool_alloc( mpool, size, file, func, lineNo );
XP_MEMSET( ptr, 0, size );
return ptr;
}
static MemPoolEntry*
findEntryFor( MemPoolCtx* mpool, void* ptr, MemPoolEntry** prevP )
{