comparison src/core/ngx_palloc.c @ 6455:ad2360782ecd

Core: introduced the NGX_DEBUG_PALLOC macro. 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.
author Valentin Bartenev <vbart@nginx.com>
date Wed, 23 Mar 2016 17:44:04 +0300
parents f61472978419
children
comparison
equal deleted inserted replaced
6454:f61472978419 6455:ad2360782ecd
120 120
121 121
122 void * 122 void *
123 ngx_palloc(ngx_pool_t *pool, size_t size) 123 ngx_palloc(ngx_pool_t *pool, size_t size)
124 { 124 {
125 #if !(NGX_DEBUG_PALLOC)
125 if (size <= pool->max) { 126 if (size <= pool->max) {
126 return ngx_palloc_small(pool, size, 1); 127 return ngx_palloc_small(pool, size, 1);
127 } 128 }
129 #endif
128 130
129 return ngx_palloc_large(pool, size); 131 return ngx_palloc_large(pool, size);
130 } 132 }
131 133
132 134
133 void * 135 void *
134 ngx_pnalloc(ngx_pool_t *pool, size_t size) 136 ngx_pnalloc(ngx_pool_t *pool, size_t size)
135 { 137 {
138 #if !(NGX_DEBUG_PALLOC)
136 if (size <= pool->max) { 139 if (size <= pool->max) {
137 return ngx_palloc_small(pool, size, 0); 140 return ngx_palloc_small(pool, size, 0);
138 } 141 }
142 #endif
139 143
140 return ngx_palloc_large(pool, size); 144 return ngx_palloc_large(pool, size);
141 } 145 }
142 146
143 147