vppinfra: add clib_mem_destroy_mspace(void *ms)
Also clib_mem_destroy() to destroy the current mspace.
Handy when an application wants to make a memory allocation arena
disappear.
Type: improvement
Signed-off-by: Dave Barach <dave@barachs.net>
Change-Id: I020db902fbe2473545506fecbc230c2b048992f8
diff --git a/src/vppinfra/mem.h b/src/vppinfra/mem.h
index 06694cc..c97ee8a 100644
--- a/src/vppinfra/mem.h
+++ b/src/vppinfra/mem.h
@@ -412,6 +412,8 @@
int clib_mem_get_fd_log2_page_size (int fd);
uword clib_mem_vm_reserve (uword start, uword size, u32 log2_page_sz);
u64 *clib_mem_vm_get_paddr (void *mem, int log2_page_size, int n_pages);
+void clib_mem_destroy_mspace (void *mspace);
+void clib_mem_destroy (void);
typedef struct
{
diff --git a/src/vppinfra/mem_dlmalloc.c b/src/vppinfra/mem_dlmalloc.c
index 663b2f1..1b0dbb2 100644
--- a/src/vppinfra/mem_dlmalloc.c
+++ b/src/vppinfra/mem_dlmalloc.c
@@ -237,6 +237,23 @@
1 /* do clib_mem_set_heap */ );
}
+void
+clib_mem_destroy_mspace (void *mspace)
+{
+ mheap_trace_main_t *tm = &mheap_trace_main;
+
+ if (tm->enabled && mspace == tm->current_traced_mheap)
+ tm->enabled = 0;
+
+ destroy_mspace (mspace);
+}
+
+void
+clib_mem_destroy (void)
+{
+ clib_mem_destroy_mspace (clib_mem_get_heap ());
+}
+
void *
clib_mem_init_thread_safe_numa (void *memory, uword memory_size, u8 numa)
{