From c00a159fd3f2afa51b35da36b4bcc89ea5939c47 Mon Sep 17 00:00:00 2001 From: YuQing <384681@qq.com> Date: Sun, 14 May 2023 20:06:27 +0800 Subject: [PATCH] fast_mblock_malloc_trunk_notify_func prototype changed --- src/fast_mblock.c | 8 ++++---- src/fast_mblock.h | 8 +++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/fast_mblock.c b/src/fast_mblock.c index 9421641..7066cca 100644 --- a/src/fast_mblock.c +++ b/src/fast_mblock.c @@ -589,8 +589,8 @@ static int fast_mblock_prealloc(struct fast_mblock_man *mblock) mblock->info.element_total_count += alloc_count; if (mblock->trunk_callbacks.notify_func != NULL) { - mblock->trunk_callbacks.notify_func(trunk_size, - mblock->trunk_callbacks.args); + mblock->trunk_callbacks.notify_func(fast_mblock_notify_type_alloc, + pMallocNode, mblock->trunk_callbacks.args); } return 0; @@ -606,8 +606,8 @@ static inline void fast_mblock_remove_trunk(struct fast_mblock_man *mblock, if (mblock->trunk_callbacks.notify_func != NULL) { - mblock->trunk_callbacks.notify_func(-1 * pMallocNode->trunk_size, - mblock->trunk_callbacks.args); + mblock->trunk_callbacks.notify_func(fast_mblock_notify_type_reclaim, + pMallocNode, mblock->trunk_callbacks.args); } } diff --git a/src/fast_mblock.h b/src/fast_mblock.h index 866e70b..5d3e8c1 100644 --- a/src/fast_mblock.h +++ b/src/fast_mblock.h @@ -39,6 +39,11 @@ #define FAST_MBLOCK_ORDER_BY_ELEMENT_SIZE 2 #define FAST_MBLOCK_ORDER_BY_USED_RATIO 3 +enum fast_mblock_notify_type { + fast_mblock_notify_type_alloc, + fast_mblock_notify_type_reclaim, +}; + /* free node chain */ struct fast_mblock_node { @@ -77,7 +82,8 @@ typedef int (*fast_mblock_malloc_trunk_check_func)( const int alloc_bytes, void *args); typedef void (*fast_mblock_malloc_trunk_notify_func)( - const int alloc_bytes, void *args); + const enum fast_mblock_notify_type type, + const struct fast_mblock_malloc *node, void *args); struct fast_mblock_info {