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; + } +}