diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2008-10-16 19:41:45 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2008-10-16 19:41:45 +0400 |
commit | 802890f0f2619ff93f543d1fcf55831cb647b174 (patch) | |
tree | 7442f1afe9ba2752425d8af5dc1f7b4f628d51d2 /mem_pool.h | |
parent | cd9b528a22e190c11d47c452b6d83fd1fbd4550c (diff) | |
download | rspamd-802890f0f2619ff93f543d1fcf55831cb647b174.tar.gz rspamd-802890f0f2619ff93f543d1fcf55831cb647b174.zip |
* Add support of shared memory chunks to memory pool allocator. Also add locking support (spin mutexes)
* Add simple test case for shared memory allocation
Diffstat (limited to 'mem_pool.h')
-rw-r--r-- | mem_pool.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/mem_pool.h b/mem_pool.h index d20a5edcd..70678e9fc 100644 --- a/mem_pool.h +++ b/mem_pool.h @@ -12,20 +12,32 @@ struct _pool_chain { size_t len; struct _pool_chain *next; }; + +struct _pool_chain_shared { + u_char *begin; + u_char *pos; + size_t len; + gint lock; + struct _pool_chain_shared *next; +}; + struct _pool_destructors { pool_destruct_func func; void *data; struct _pool_destructors *prev; }; + typedef struct memory_pool_s { struct _pool_chain *cur_pool; struct _pool_chain *first_pool; + struct _pool_chain_shared *shared_pool; struct _pool_destructors *destructors; } memory_pool_t; typedef struct memory_pool_stat_s { size_t bytes_allocated; size_t chunks_allocated; + size_t shared_chunks_allocated; size_t chunks_freed; } memory_pool_stat_t; @@ -34,6 +46,9 @@ void* memory_pool_alloc (memory_pool_t* pool, size_t size); void* memory_pool_alloc0 (memory_pool_t* pool, size_t size); char* memory_pool_strdup (memory_pool_t* pool, const char *src); void memory_pool_add_destructor (memory_pool_t *pool, pool_destruct_func func, void *data); +void* memory_pool_alloc_shared (memory_pool_t *pool, size_t size); +void memory_pool_lock_shared (memory_pool_t *pool, void *pointer); +void memory_pool_unlock_shared (memory_pool_t *pool, void *pointer); void memory_pool_delete (memory_pool_t* pool); void memory_pool_stat (memory_pool_stat_t *st); |