From f0732bbcbdca67ef8f9444f2aafaf44da81c9e5a Mon Sep 17 00:00:00 2001
From: wangzhengquan <wangzhengquan85@126.com>
Date: 星期六, 01 八月 2020 16:44:00 +0800
Subject: [PATCH] update
---
src/queue/include/mem_pool.h | 28 ++++++++++++----------------
1 files changed, 12 insertions(+), 16 deletions(-)
diff --git a/src/queue/include/mem_pool.h b/src/queue/include/mem_pool.h
index 72ad5b7..2ea1f6b 100644
--- a/src/queue/include/mem_pool.h
+++ b/src/queue/include/mem_pool.h
@@ -34,6 +34,15 @@
return ptr;
}
+
+static inline void mem_pool_free (void *ptr) {
+ mm_free(ptr);
+ // notify malloc
+ SemUtil::set(mem_pool_cond, 1);
+
+}
+
+
template <typename T>
static inline T* mem_pool_attach(int key) {
void *ptr;
@@ -51,30 +60,17 @@
}
static inline void mem_pool_free_by_key(int key) {
- void *ptr;
- // T* tptr;
- hashtable_t *hashtable = mm_get_hashtable();
- ptr = hashtable_get(hashtable, key);
- if(ptr != NULL) {
- mm_free(ptr);
- hashtable_remove(hashtable, key);
- }
+ return mm_free_by_key(key);
}
-static inline void mem_pool_free (void *ptr) {
- mm_free(ptr);
- // notify malloc
- SemUtil::set(mem_pool_cond, 1);
-
-}
static inline void *mem_pool_realloc (void *ptr, size_t size) {
return mm_realloc(ptr, size);
}
static inline int mem_pool_alloc_key() {
- hashtable_t *hashtable = mm_get_hashtable();
- return hashtable_alloc_key(hashtable);
+
+ return mm_alloc_key();
}
--
Gitblit v1.8.0