add function fast_mblock_init_ex1

pull/5/head
yuqing 2015-11-16 13:48:26 +08:00
parent b6eb0e20da
commit 9828c45343
2 changed files with 24 additions and 5 deletions

View File

@ -1,5 +1,5 @@
Version 1.23 2015-11-13
Version 1.23 2015-11-16
* sched_thread.c: task can execute in a new thread
* sched_thread.c: support delay tasks
* add function get_current_time_us and get_current_time_ms

View File

@ -132,15 +132,34 @@ parameters:
need_lock: if need lock
malloc_trunk_check: the malloc trunk check function pointor
malloc_trunk_notify: the malloc trunk notify function pointor
malloc_trunk__args: the malloc trunk args
malloc_trunk_args: the malloc trunk args
return error no, 0 for success, != 0 fail
*/
int fast_mblock_init_ex2(struct fast_mblock_man *mblock, const char *name,
const int element_size, const int alloc_elements_once,
fast_mblock_alloc_init_func init_func, const bool need_lock,
fast_mblock_malloc_trunk_check_func malloc_trunk_check,
fast_mblock_malloc_trunk_notify_func malloc_trunk_notify,
void *malloc_trunk_args);
fast_mblock_malloc_trunk_check_func malloc_trunk_check,
fast_mblock_malloc_trunk_notify_func malloc_trunk_notify,
void *malloc_trunk_args);
/**
mblock init
parameters:
name: the mblock name
mblock: the mblock pointer
element_size: element size, such as sizeof(struct xxx)
alloc_elements_once: malloc elements once, 0 for malloc 1MB memory once
init_func: the init function
need_lock: if need lock
return error no, 0 for success, != 0 fail
*/
static inline int fast_mblock_init_ex1(struct fast_mblock_man *mblock,
const char *name, const int element_size, const int alloc_elements_once,
fast_mblock_alloc_init_func init_func, const bool need_lock)
{
return fast_mblock_init_ex2(mblock, name, element_size,
alloc_elements_once, init_func, need_lock, NULL, NULL, NULL);
}
/**
mblock destroy