mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-26 09:58:20 +01:00
add a calloc to mempool
This commit is contained in:
parent
b5e1e3a2c6
commit
c7729ca25c
2 changed files with 11 additions and 0 deletions
|
@ -178,6 +178,8 @@ typedef struct CommonPrefs {
|
||||||
#ifdef MEM_DEBUG
|
#ifdef MEM_DEBUG
|
||||||
# define XP_MALLOC(pool,nbytes) \
|
# define XP_MALLOC(pool,nbytes) \
|
||||||
mpool_alloc((pool),(nbytes),__FILE__,__func__, __LINE__)
|
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) \
|
# define XP_REALLOC(pool,p,s) \
|
||||||
mpool_realloc((pool),(p),(s),__FILE__,__func__,__LINE__)
|
mpool_realloc((pool),(p),(s),__FILE__,__func__,__LINE__)
|
||||||
# define XP_FREE(pool,p) \
|
# define XP_FREE(pool,p) \
|
||||||
|
|
|
@ -161,6 +161,15 @@ mpool_alloc( MemPoolCtx* mpool, XP_U32 size, const char* file,
|
||||||
return entry->ptr;
|
return entry->ptr;
|
||||||
} /* mpool_alloc */
|
} /* 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*
|
static MemPoolEntry*
|
||||||
findEntryFor( MemPoolCtx* mpool, void* ptr, MemPoolEntry** prevP )
|
findEntryFor( MemPoolCtx* mpool, void* ptr, MemPoolEntry** prevP )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue