Mercurial > hg > nginx
diff src/core/ngx_slab.c @ 5726:25ade23cf281
Core: added ngx_slab_calloc() and ngx_slab_calloc_locked().
These functions return zeroed memory, analogous to ngx_pcalloc().
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Wed, 04 Jun 2014 15:09:19 +0400 |
parents | c46657e391a3 |
children | abdb027be9d5 |
line wrap: on
line diff
--- a/src/core/ngx_slab.c +++ b/src/core/ngx_slab.c @@ -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) {