From 65eba4b692e4f3846b7f3e9824f03c9767cf25f6 Mon Sep 17 00:00:00 2001 From: Igor Sysoev Date: Tue, 25 Nov 2008 14:25:20 +0000 Subject: [PATCH] ngx_reset_pool() --- src/core/ngx_palloc.c | 20 ++++++++++++++++++++ src/core/ngx_palloc.h | 1 + 2 files changed, 21 insertions(+) diff --git a/src/core/ngx_palloc.c b/src/core/ngx_palloc.c index ce826bab6..7c89fda70 100644 --- a/src/core/ngx_palloc.c +++ b/src/core/ngx_palloc.c @@ -91,6 +91,26 @@ ngx_destroy_pool(ngx_pool_t *pool) } +void +ngx_reset_pool(ngx_pool_t *pool) +{ + ngx_pool_t *p; + ngx_pool_large_t *l; + + for (l = pool->large; l; l = l->next) { + if (l->alloc) { + ngx_free(l->alloc); + } + } + + pool->large = NULL; + + for (p = pool; p; p = p->d.next) { + p->d.last = (u_char *) p + sizeof(ngx_pool_t); + } +} + + void * ngx_palloc(ngx_pool_t *pool, size_t size) { diff --git a/src/core/ngx_palloc.h b/src/core/ngx_palloc.h index 2b3a30cbd..434f9728b 100644 --- a/src/core/ngx_palloc.h +++ b/src/core/ngx_palloc.h @@ -73,6 +73,7 @@ void *ngx_calloc(size_t size, ngx_log_t *log); ngx_pool_t *ngx_create_pool(size_t size, ngx_log_t *log); void ngx_destroy_pool(ngx_pool_t *pool); +void ngx_reset_pool(ngx_pool_t *pool); void *ngx_palloc(ngx_pool_t *pool, size_t size); void *ngx_pnalloc(ngx_pool_t *pool, size_t size);