aboutsummaryrefslogtreecommitdiff
path: root/src/core/ngx_slab.c
diff options
context:
space:
mode:
authorRuslan Ermilov <ru@nginx.com>2014-06-04 15:09:19 +0400
committerRuslan Ermilov <ru@nginx.com>2014-06-04 15:09:19 +0400
commit05d717b35d02c493533f6244a85b6c78a59f4272 (patch)
tree0be8ef3eb996dc2cacb775005e1d7a734a809ae5 /src/core/ngx_slab.c
parentd1ba20d0c971f4a76fef5ba8d39e757b9a7fa3af (diff)
downloadnginx-05d717b35d02c493533f6244a85b6c78a59f4272.tar.gz
nginx-05d717b35d02c493533f6244a85b6c78a59f4272.zip
Core: added ngx_slab_calloc() and ngx_slab_calloc_locked().
These functions return zeroed memory, analogous to ngx_pcalloc().
Diffstat (limited to 'src/core/ngx_slab.c')
-rw-r--r--src/core/ngx_slab.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/core/ngx_slab.c b/src/core/ngx_slab.c
index be3e54084..24f2ff16a 100644
--- 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)
{