Skip to content

Commit

Permalink
Core: removed meaningless check from ngx_palloc_block().
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
mdounin committed Jun 25, 2014
1 parent 25250a2 commit 9d4de05
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/core/ngx_palloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ ngx_palloc_block(ngx_pool_t *pool, size_t size)
{
u_char *m;
size_t psize;
ngx_pool_t *p, *new, *current;
ngx_pool_t *p, *new;

psize = (size_t) (pool->d.end - (u_char *) pool);

Expand All @@ -200,18 +200,14 @@ ngx_palloc_block(ngx_pool_t *pool, size_t size)
m = ngx_align_ptr(m, NGX_ALIGNMENT);
new->d.last = m + size;

current = pool->current;

for (p = current; p->d.next; p = p->d.next) {
for (p = pool->current; p->d.next; p = p->d.next) {
if (p->d.failed++ > 4) {
current = p->d.next;
pool->current = p->d.next;
}
}

p->d.next = new;

pool->current = current ? current : new;

return m;
}

Expand Down

0 comments on commit 9d4de05

Please sign in to comment.