]> git.kaiwu.me - nginx.git/commitdiff
fix the previous commit
authorIgor Sysoev <igor@sysoev.ru>
Fri, 20 Jun 2008 21:06:53 +0000 (21:06 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Fri, 20 Jun 2008 21:06:53 +0000 (21:06 +0000)
src/core/ngx_palloc.c

index 8c69db77332cb1e96469ae1ca85c68cb5f065c31..971887fd4c4a16feaaeca22898c514736a6fe872 100644 (file)
@@ -159,14 +159,19 @@ ngx_palloc_block(ngx_pool_t *pool, size_t size)
 
     psize = (size_t) (pool->d.end - (u_char *) pool);
 
-    new = ngx_alloc(size, pool->log);
-    if (new == NULL) {
+    m = ngx_alloc(psize, pool->log);
+    if (m == NULL) {
         return NULL;
     }
 
-    new->d.end = (u_char *) new + psize;
+    new = (ngx_pool_t *) m;
+
+    new->d.end = m + psize;
     new->d.next = NULL;
 
+    m += sizeof(ngx_pool_data_t);
+    new->d.last = m + size;
+
     current = pool->current;
 
     for (p = current; p->d.next; p = p->d.next) {
@@ -179,9 +184,6 @@ ngx_palloc_block(ngx_pool_t *pool, size_t size)
 
     pool->current = current ? current : new;
 
-    m = (u_char *) new + sizeof(ngx_pool_data_t);
-    new->d.last = m + size;
-
     return m;
 }