diff --git a/lib/mempool.c b/lib/mempool.c index 5200f5e7..be98de51 100644 --- a/lib/mempool.c +++ b/lib/mempool.c @@ -185,11 +185,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;