From 31b1e1a80137f9f1dfd92d2c645ae3f3e83015d5 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Mon, 25 Oct 1999 07:54:28 +0000 Subject: [PATCH] Better version of clearable pools. --- lib/pool.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/pool.c b/lib/pool.c index 8c352f0f..7fc635d3 100644 --- a/lib/pool.c +++ b/lib/pool.c @@ -1,7 +1,7 @@ /* * Sherlock Library -- Memory Pools (One-Time Allocation) * - * (c) 1997 Martin Mares, + * (c) 1997--1999 Martin Mares */ #include @@ -71,9 +71,12 @@ pool_alloc(struct mempool *p, uns s) { struct memchunk *c; - if (p->current && p->current->next) - /* Still have free chunks from previous incarnation */ - c = p->current->next; + if (p->current) + { + /* Still have free chunks from previous incarnation */ + c = p->current; + p->current = c->next; + } else { c = xmalloc(sizeof(struct memchunk) + p->chunk_size); @@ -81,7 +84,6 @@ pool_alloc(struct mempool *p, uns s) p->plast = &c->next; c->next = NULL; } - p->current = c; x = c->data; p->last = x + p->chunk_size; } -- 2.39.5