]> git.kaiwu.me - nginx.git/commitdiff
Core: introduced the NGX_DEBUG_PALLOC macro.
authorValentin Bartenev <vbart@nginx.com>
Wed, 23 Mar 2016 14:44:04 +0000 (17:44 +0300)
committerValentin Bartenev <vbart@nginx.com>
Wed, 23 Mar 2016 14:44:04 +0000 (17:44 +0300)
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.

src/core/ngx_palloc.c

index 91e7cd71cd21e2600caf213d10be160aabcb160a..d3044ac9c57211f9d548f8a40c06482d630f0fd9 100644 (file)
@@ -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);
 }
@@ -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);
 }