Mercurial > hg > nginx
comparison 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 |
comparison
equal
deleted
inserted
replaced
5725:eadf46f888e9 | 5726:25ade23cf281 |
---|---|
396 | 396 |
397 return (void *) p; | 397 return (void *) p; |
398 } | 398 } |
399 | 399 |
400 | 400 |
401 void * | |
402 ngx_slab_calloc(ngx_slab_pool_t *pool, size_t size) | |
403 { | |
404 void *p; | |
405 | |
406 ngx_shmtx_lock(&pool->mutex); | |
407 | |
408 p = ngx_slab_calloc_locked(pool, size); | |
409 | |
410 ngx_shmtx_unlock(&pool->mutex); | |
411 | |
412 return p; | |
413 } | |
414 | |
415 | |
416 void * | |
417 ngx_slab_calloc_locked(ngx_slab_pool_t *pool, size_t size) | |
418 { | |
419 void *p; | |
420 | |
421 p = ngx_slab_alloc_locked(pool, size); | |
422 if (p) { | |
423 ngx_memzero(p, size); | |
424 } | |
425 | |
426 return p; | |
427 } | |
428 | |
429 | |
401 void | 430 void |
402 ngx_slab_free(ngx_slab_pool_t *pool, void *p) | 431 ngx_slab_free(ngx_slab_pool_t *pool, void *p) |
403 { | 432 { |
404 ngx_shmtx_lock(&pool->mutex); | 433 ngx_shmtx_lock(&pool->mutex); |
405 | 434 |