From e50769c824d6e161e4e92e65c785b2388bf5d130 Mon Sep 17 00:00:00 2001 From: Lephe Date: Sun, 4 Feb 2024 22:10:01 +0100 Subject: [PATCH] kmalloc: add kmalloc_remove_arena() function --- include/gint/kmalloc.h | 5 +++++ src/kmalloc/kmalloc.c | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/include/gint/kmalloc.h b/include/gint/kmalloc.h index de2496e..89a2633 100644 --- a/include/gint/kmalloc.h +++ b/include/gint/kmalloc.h @@ -108,6 +108,11 @@ void kmalloc_init_arena(kmalloc_arena_t *a, bool enable_statistics); success, false if the maximum number of arenas has been reached. */ bool kmalloc_add_arena(kmalloc_arena_t *arena); +/* kmalloc_remove_arena(): Remove an arena from the heap source + Removes an arena from the heap source. The arena should certainly be empty, + although this function will not check that. */ +void kmalloc_remove_arena(kmalloc_arena_t *arena); + //--- // Internal functions //--- diff --git a/src/kmalloc/kmalloc.c b/src/kmalloc/kmalloc.c index c734c32..147e6d5 100644 --- a/src/kmalloc/kmalloc.c +++ b/src/kmalloc/kmalloc.c @@ -184,3 +184,12 @@ bool kmalloc_add_arena(kmalloc_arena_t *arena) } return false; } + +void kmalloc_remove_arena(kmalloc_arena_t *arena) +{ + for(int i = 0; i < KMALLOC_ARENA_MAX; i++) + { + if(arenas[i] == arena) + arenas[i] = NULL; + } +}