aboutsummaryrefslogtreecommitdiffstats
path: root/mem_pool.h
diff options
context:
space:
mode:
authorcebka@mailsupport.rambler.ru <cebka@mailsupport.rambler.ru>2008-09-23 11:47:56 +0400
committercebka@mailsupport.rambler.ru <cebka@mailsupport.rambler.ru>2008-09-23 11:47:56 +0400
commit193acf73e51b24ccca8048ebb6aaec2971594268 (patch)
treea094617b2bb6c5d867584830f2ac4c6fa5f7b8fa /mem_pool.h
parent2b65ae425b9dca345bea158471b358d3c17b9704 (diff)
downloadrspamd-193acf73e51b24ccca8048ebb6aaec2971594268.tar.gz
rspamd-193acf73e51b24ccca8048ebb6aaec2971594268.zip
* Small updates to memory pool library
- fix cases when new chunk is allocated - add memory pool allocator statistics - let it work in multi-threaded environment - add strdup function for convinience * Use memory pool allocator more widely to avoid memory leaks in future and optimize performance * Task pool chunk size is now pre-defined constant (16 Kb currently)
Diffstat (limited to 'mem_pool.h')
-rw-r--r--mem_pool.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/mem_pool.h b/mem_pool.h
index 0927d9197..1e2c020ca 100644
--- a/mem_pool.h
+++ b/mem_pool.h
@@ -14,10 +14,19 @@ typedef struct memory_pool_s {
struct _pool_chain *first_pool;
} memory_pool_t;
+typedef struct memory_pool_stat_s {
+ size_t bytes_allocated;
+ size_t chunks_allocated;
+ size_t chunks_freed;
+} memory_pool_stat_t;
+
memory_pool_t* memory_pool_new (size_t size);
void* memory_pool_alloc (memory_pool_t* pool, size_t size);
+char* memory_pool_strdup (memory_pool_t* pool, const char *src);
void memory_pool_delete (memory_pool_t* pool);
-#define memory_pool_free(x) ((x)->pos - (x)->begin)
+void memory_pool_stat (memory_pool_stat_t *st);
+
+#define memory_pool_free(x) ((x)->len - ((x)->pos - (x)->begin))
#endif