mirror of
https://github.com/zlgopen/awtk.git
synced 2025-05-08 19:44:45 +08:00
improve mem_allocator_fixed_block
This commit is contained in:
parent
efab099c37
commit
ae9802fbc8
@ -2,6 +2,7 @@
|
||||
|
||||
2025/04/15
|
||||
* 增加mem_allocator_fixed_block,dlist/slist/tree使用该内存分配器管理内存(感谢兆坤提供补丁)。
|
||||
* 完善mem_allocator_fixed_block(感谢兆坤提供补丁)。
|
||||
|
||||
2025/04/14
|
||||
* conf_io 支持 YAML格式。
|
||||
|
@ -30,10 +30,12 @@ static dlist_node_t* dlist_create_node(dlist_t* dlist, void* data) {
|
||||
if (dlist->node_allocator != NULL) {
|
||||
ret = mem_allocator_alloc(dlist->node_allocator, sizeof(dlist_node_t), __FUNCTION__, __LINE__);
|
||||
} else {
|
||||
ret = TKMEM_ZALLOC(dlist_node_t);
|
||||
ret = TKMEM_ALLOC(sizeof(dlist_node_t));
|
||||
}
|
||||
return_value_if_fail(ret != NULL, NULL);
|
||||
|
||||
memset(ret, 0, sizeof(*ret));
|
||||
|
||||
ret->data = data;
|
||||
|
||||
return ret;
|
||||
|
@ -186,10 +186,13 @@ inline static mem_allocator_fixed_block_pool_t* mem_allocator_fixed_block_pool_c
|
||||
mem_allocator_fixed_block_pool_t* ret = NULL;
|
||||
return_value_if_fail(allocator != NULL && num > 0, NULL);
|
||||
|
||||
ret = TKMEM_CALLOC(1, MEM_ALLOCATOR_FIXED_BLOCK_POOL_SIZE(allocator->size, num));
|
||||
ret = TKMEM_ALLOC(MEM_ALLOCATOR_FIXED_BLOCK_POOL_SIZE(allocator->size, num));
|
||||
return_value_if_fail(ret != NULL, NULL);
|
||||
|
||||
ret->num = num;
|
||||
ret->used_units = NULL;
|
||||
ret->unused_units = NULL;
|
||||
ret->next = NULL;
|
||||
|
||||
mem_allocator_fixed_block_pool_init(allocator, ret);
|
||||
|
||||
|
@ -30,10 +30,12 @@ static slist_node_t* slist_create_node(slist_t* slist, void* data) {
|
||||
if (slist->node_allocator != NULL) {
|
||||
ret = mem_allocator_alloc(slist->node_allocator, sizeof(slist_node_t), __FUNCTION__, __LINE__);
|
||||
} else {
|
||||
ret = TKMEM_ZALLOC(slist_node_t);
|
||||
ret = TKMEM_ALLOC(sizeof(slist_node_t));
|
||||
}
|
||||
return_value_if_fail(ret != NULL, NULL);
|
||||
|
||||
memset(ret, 0, sizeof(*ret));
|
||||
|
||||
ret->data = data;
|
||||
|
||||
return ret;
|
||||
|
@ -254,10 +254,12 @@ static inline tree_node_t* tree_node_create(void* data, mem_allocator_t* allocat
|
||||
if (allocator != NULL) {
|
||||
ret = mem_allocator_alloc(allocator, sizeof(tree_node_t), __FUNCTION__, __LINE__);
|
||||
} else {
|
||||
ret = TKMEM_ZALLOC(tree_node_t);
|
||||
ret = TKMEM_ALLOC(sizeof(tree_node_t));
|
||||
}
|
||||
return_value_if_fail(ret != NULL, NULL);
|
||||
|
||||
memset(ret, 0, sizeof(*ret));
|
||||
|
||||
ret->data = data;
|
||||
|
||||
return ret;
|
||||
|
Loading…
x
Reference in New Issue
Block a user