46 lines
1.0 KiB
Diff
46 lines
1.0 KiB
Diff
From 2ca49371b548b56d192f571866fb28c548746ad1 Mon Sep 17 00:00:00 2001
|
|
From: Huaxin Lu <luhuaxin1@huawei.com>
|
|
Date: Mon, 19 Feb 2024 10:35:34 +0800
|
|
Subject: [PATCH 20/26] Add memory debug in mem_pool
|
|
|
|
---
|
|
src/core/dim_core_mem_pool.c | 8 ++++++++
|
|
1 file changed, 8 insertions(+)
|
|
|
|
diff --git a/src/core/dim_core_mem_pool.c b/src/core/dim_core_mem_pool.c
|
|
index 974033f..a9f0177 100644
|
|
--- a/src/core/dim_core_mem_pool.c
|
|
+++ b/src/core/dim_core_mem_pool.c
|
|
@@ -4,6 +4,7 @@
|
|
|
|
#include <linux/mm.h>
|
|
|
|
+#include "dim_safe_func.h"
|
|
#include "dim_utils.h"
|
|
|
|
#include "dim_core_mem_pool.h"
|
|
@@ -108,6 +109,9 @@ void *dim_mem_pool_alloc(size_t size)
|
|
if (data == NULL)
|
|
return NULL;
|
|
out:
|
|
+ #ifdef DIM_DEBUG_MEMORY_LEAK
|
|
+ dim_alloc_debug_inc();
|
|
+ #endif
|
|
data->size = mem_size;
|
|
return data->data;
|
|
}
|
|
@@ -130,6 +134,10 @@ void dim_mem_pool_free(const void *data)
|
|
}
|
|
|
|
gen_pool_free(dim_pool, (uintptr_t)mem, mem->size);
|
|
+
|
|
+ #ifdef DIM_DEBUG_MEMORY_LEAK
|
|
+ dim_alloc_debug_dec();
|
|
+ #endif
|
|
}
|
|
|
|
void dim_mem_pool_walk_chunk(pool_chunk_visitor f, void *data)
|
|
--
|
|
2.33.0
|
|
|