From: Martin Mares Date: Mon, 25 Oct 1999 07:54:28 +0000 (+0000) Subject: Better version of clearable pools. X-Git-Tag: holmes-import~1661 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=31b1e1a80137f9f1dfd92d2c645ae3f3e83015d5;p=libucw.git Better version of clearable pools. --- 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; }