comparison src/core/ngx_palloc.c @ 5742:c45c9812cf11

Core: removed meaningless check from ngx_palloc_block(). The check became meaningless after refactoring in 2a92804f4109. With the loop currently in place, "current" can't be NULL, hence the check can be dropped. Additionally, the local variable "current" was removed to simplify code, and pool->current now used directly instead. Found by Coverity (CID 714236).
author Maxim Dounin <mdounin@mdounin.ru>
date Thu, 26 Jun 2014 03:34:19 +0400
parents 320abeb364e6
children 6be7e59fdd2c
comparison
equal deleted inserted replaced
5741:b490bfbf8cfa 5742:c45c9812cf11
179 static void * 179 static void *
180 ngx_palloc_block(ngx_pool_t *pool, size_t size) 180 ngx_palloc_block(ngx_pool_t *pool, size_t size)
181 { 181 {
182 u_char *m; 182 u_char *m;
183 size_t psize; 183 size_t psize;
184 ngx_pool_t *p, *new, *current; 184 ngx_pool_t *p, *new;
185 185
186 psize = (size_t) (pool->d.end - (u_char *) pool); 186 psize = (size_t) (pool->d.end - (u_char *) pool);
187 187
188 m = ngx_memalign(NGX_POOL_ALIGNMENT, psize, pool->log); 188 m = ngx_memalign(NGX_POOL_ALIGNMENT, psize, pool->log);
189 if (m == NULL) { 189 if (m == NULL) {
198 198
199 m += sizeof(ngx_pool_data_t); 199 m += sizeof(ngx_pool_data_t);
200 m = ngx_align_ptr(m, NGX_ALIGNMENT); 200 m = ngx_align_ptr(m, NGX_ALIGNMENT);
201 new->d.last = m + size; 201 new->d.last = m + size;
202 202
203 current = pool->current; 203 for (p = pool->current; p->d.next; p = p->d.next) {
204
205 for (p = current; p->d.next; p = p->d.next) {
206 if (p->d.failed++ > 4) { 204 if (p->d.failed++ > 4) {
207 current = p->d.next; 205 pool->current = p->d.next;
208 } 206 }
209 } 207 }
210 208
211 p->d.next = new; 209 p->d.next = new;
212
213 pool->current = current ? current : new;
214 210
215 return m; 211 return m;
216 } 212 }
217 213
218 214