design_pattern_for_c  V 1.00
memorypool.h
Go to the documentation of this file.
1 
5 #ifndef MEMORYPOOL_H
6 #define MEMORYPOOL_H
7 
10 struct memorypool_t;
12 typedef struct memorypool_t * MemoryPool;
13 
25 MemoryPool mpool_create(size_t max_size, size_t max_cnt, int is_multithread, void (*constructor)(void * this, void *constructor_parameter), void *constructor_parameter);
33 void mpool_delete(MemoryPool this, void (*destructor)(void *));
34 
43 void * mpool_get(MemoryPool this);
52 void * mpool_get_next_usedmem(MemoryPool this, void * ptr);
53 
55 #define FOR_ALL_USEDMEM(this,ptr) for(ptr=mpool_get_next_usedmem(this, NULL); ptr!=NULL; ptr = mpool_get_next_usedmem(this, ptr ))
56 
63 size_t mpool_get_usedcnt(MemoryPool this);
72 void mpool_release(MemoryPool this, void * ptr);
73 #endif
void mpool_delete(MemoryPool this, void(*destructor)(void *))
free MemoryPool class
Definition: memorypool.c:223
size_t mpool_get_usedcnt(MemoryPool this)
get used cnt
Definition: memorypool.c:257
size_t max_size
Definition: memorypool.c:48
void * mpool_get(MemoryPool this)
get memory from pool
Definition: memorypool.c:236
struct memorypool_t * MemoryPool
MemoryPool class definition, to use API.
Definition: memorypool.h:12
void * mpool_get_next_usedmem(MemoryPool this, void *ptr)
get used memory
Definition: memorypool.c:245
void mpool_release(MemoryPool this, void *ptr)
release memory to pool
Definition: memorypool.c:266
MemoryPool mpool_create(size_t max_size, size_t max_cnt, int is_multithread, void(*constructor)(void *this, void *constructor_parameter), void *constructor_parameter)
create MemoryPool class
size_t max_cnt
Definition: memorypool.c:49
MemoryPool class member definition, detail is defined in C file.
Definition: memorypool.c:45