diff --git a/lib/mempool.c b/lib/mempool.c index 325b1ecf..7c306e99 100644 --- a/lib/mempool.c +++ b/lib/mempool.c @@ -187,11 +187,18 @@ lp_flush(linpool *m) { struct lp_chunk *c; - /* Move ptr to the first chunk and free all large chunks */ + /* Move ptr to the first chunk and free all other chunks */ m->current = c = m->first; m->ptr = c ? c->data : NULL; m->end = c ? c->data + LP_DATA_SIZE : NULL; + while (c && c->next) + { + struct lp_chunk *d = c->next; + c->next = d->next; + free_page(d); + } + while (c = m->first_large) { m->first_large = c->next;