diff src/core/ngx_alloc.c @ 128:1947c683490f

nginx-0.0.1-2003-08-08-19:13:24 import
author Igor Sysoev <igor@sysoev.ru>
date Fri, 08 Aug 2003 15:13:24 +0000
parents fcc79370b9a8
children b27548f540ad
line wrap: on
line diff
--- a/src/core/ngx_alloc.c
+++ b/src/core/ngx_alloc.c
@@ -59,20 +59,25 @@ void ngx_destroy_pool(ngx_pool_t *pool)
         free(l->alloc);
     }
 
-    /* we can use pool->log so we have to free() pool after all */
+    /*
+     * we could allocate pool->log from this pool
+     * so we can not use this log while free()ing the pool
+     */
 
-    for (p = pool->next; p ; p = n) {
 #if (NGX_DEBUG_ALLOC)
+    for (p = pool, n = pool->next; /* void */; p = n, n = n->next) {
         ngx_log_debug(pool->log, "free: %08x" _ p);
+    }
 #endif
-        n = p->next;
+
+    for (p = pool, n = pool->next; /* void */; p = n, n = n->next) {
         free(p);
+
+        if (n == NULL) {
+            break;
+        }
     }
 
-#if (NGX_DEBUG_ALLOC)
-    ngx_log_debug(pool->log, "free: %08x" _ pool);
-#endif
-    free(pool);
     pool = NULL;
 }