From 20ae90ee37f071d03fbad5c15b352f7587fd1de7 Mon Sep 17 00:00:00 2001 From: RinHizakura Date: Fri, 29 Sep 2023 02:28:36 +0800 Subject: [PATCH] Reclaim memory when destroying mpool correctly --- src/mpool.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mpool.c b/src/mpool.c index ff65b5bd..feb8b194 100644 --- a/src/mpool.c +++ b/src/mpool.c @@ -141,6 +141,8 @@ void mpool_destroy(mpool_t *mp) tmp = cur; cur = cur->next; munmap(tmp->mapped, mem_size); + if (tmp != &mp->area) + free(tmp); } #else area_t *cur = &mp->area, *tmp = NULL; @@ -148,6 +150,8 @@ void mpool_destroy(mpool_t *mp) tmp = cur; cur = cur->next; free(tmp->mapped); + if (tmp != &mp->area) + free(tmp); } #endif free(mp);