--- libelwix/src/mem.c 2024/10/26 14:55:56 1.10.8.1 +++ libelwix/src/mem.c 2024/10/28 09:58:51 1.11 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: mem.c,v 1.10.8.1 2024/10/26 14:55:56 misho Exp $ +* $Id: mem.c,v 1.11 2024/10/28 09:58:51 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -91,7 +91,7 @@ mpool_init(u_long maxmem) void mpool_destroy(mpool_t ** __restrict mp) { - struct tagAlloc *m; + struct tagAlloc *m, *n; register int i; if (!mp || !*mp) @@ -100,14 +100,14 @@ mpool_destroy(mpool_t ** __restrict mp) mpool_lock(*mp); for (i = 0; i < MEM_BUCKETS; i++) { - while ((m = TAILQ_FIRST(&(*mp)->pool_active[i]))) { - TAILQ_REMOVE(&(*mp)->pool_active[i], m, alloc_node); + for (m = TAILQ_FIRST(&(*mp)->pool_active[i]); m; m = n) { + n = TAILQ_NEXT(m, alloc_node); if (m->alloc_mem) free(m->alloc_mem); free(m); } - while ((m = TAILQ_FIRST(&(*mp)->pool_inactive[i]))) { - TAILQ_REMOVE(&(*mp)->pool_inactive[i], m, alloc_node); + for (m = TAILQ_FIRST(&(*mp)->pool_inactive[i]); m; m = n) { + n = TAILQ_NEXT(m, alloc_node); if (m->alloc_mem) free(m->alloc_mem); free(m);