Skip to content

Commit

Permalink
Core: introduced the NGX_DEBUG_PALLOC macro.
Browse files Browse the repository at this point in the history
It allows to turn off accumulation of small pool allocations into a big
preallocated chunk of memory.  This is useful for debugging memory access
with sanitizer, since such accumulation can cover buffer overruns from
being detected.
  • Loading branch information
VBart committed Mar 23, 2016
1 parent 9d08bda commit 0f4315f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/core/ngx_palloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,11 @@ ngx_reset_pool(ngx_pool_t *pool)
void *
ngx_palloc(ngx_pool_t *pool, size_t size)
{
#if !(NGX_DEBUG_PALLOC)
if (size <= pool->max) {
return ngx_palloc_small(pool, size, 1);
}
#endif

return ngx_palloc_large(pool, size);
}
Expand All @@ -133,9 +135,11 @@ ngx_palloc(ngx_pool_t *pool, size_t size)
void *
ngx_pnalloc(ngx_pool_t *pool, size_t size)
{
#if !(NGX_DEBUG_PALLOC)
if (size <= pool->max) {
return ngx_palloc_small(pool, size, 0);
}
#endif

return ngx_palloc_large(pool, size);
}
Expand Down

0 comments on commit 0f4315f

Please sign in to comment.