mirror of
https://github.com/nginx/nginx.git
synced 2025-02-25 18:55:26 -06:00
Core: added ngx_slab_calloc() and ngx_slab_calloc_locked().
These functions return zeroed memory, analogous to ngx_pcalloc().
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user