Core: added ngx_slab_calloc() and ngx_slab_calloc_locked().

These functions return zeroed memory, analogous to ngx_pcalloc().
This commit is contained in:
Ruslan Ermilov
2014-06-04 15:09:19 +04:00
parent d1ba20d0c9
commit 05d717b35d
3 changed files with 37 additions and 16 deletions

View File

@@ -398,6 +398,35 @@ done:
}
void *
ngx_slab_calloc(ngx_slab_pool_t *pool, size_t size)
{
void *p;
ngx_shmtx_lock(&pool->mutex);
p = ngx_slab_calloc_locked(pool, size);
ngx_shmtx_unlock(&pool->mutex);
return p;
}
void *
ngx_slab_calloc_locked(ngx_slab_pool_t *pool, size_t size)
{
void *p;
p = ngx_slab_alloc_locked(pool, size);
if (p) {
ngx_memzero(p, size);
}
return p;
}
void
ngx_slab_free(ngx_slab_pool_t *pool, void *p)
{