From e77c0c359903cd94e43db8cc872778d3269f8d53 Mon Sep 17 00:00:00 2001 From: Igor Sysoev Date: Fri, 8 Aug 2003 15:13:24 +0000 Subject: nginx-0.0.1-2003-08-08-19:13:24 import --- src/core/ngx_alloc.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/core/ngx_alloc.c') diff --git a/src/core/ngx_alloc.c b/src/core/ngx_alloc.c index 110ab0161..311a34e26 100644 --- 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; } -- cgit v1.2.3