bugfixed: array_allocator_alloc MUST init the array

pull/47/head
YuQing 2023-08-02 14:53:27 +08:00
parent 1969fbba8d
commit fafbbb557e
5 changed files with 11 additions and 4 deletions

View File

@ -1,4 +1,7 @@
Version 1.69 2023-08-02
* bugfixed: array_allocator_alloc MUST init the array
Version 1.68 2023-07-05
* sorted_queue.[hc]: pop_compare_func support argument

View File

@ -58,6 +58,7 @@ VoidArray *array_allocator_alloc(ArrayAllocatorContext *ctx,
{
int alloc;
int bytes;
VoidArray *array;
if (target_count <= ctx->min_count) {
alloc = ctx->min_count;
@ -71,7 +72,11 @@ VoidArray *array_allocator_alloc(ArrayAllocatorContext *ctx,
}
bytes = sizeof(VoidArray) + alloc * ctx->element_size;
return (VoidArray *)fast_allocator_alloc(&ctx->allocator, bytes);
if ((array=fast_allocator_alloc(&ctx->allocator, bytes)) != NULL) {
array->alloc = alloc;
array->count = 0;
}
return array;
}
VoidArray *array_allocator_realloc(ArrayAllocatorContext *ctx,

View File

@ -78,7 +78,6 @@ extern "C" {
static inline void array_allocator_free(ArrayAllocatorContext *ctx,
VoidArray *array)
{
array->count = 0;
fast_allocator_free(&ctx->allocator, array);
}

View File

@ -1163,6 +1163,7 @@ OUTER:
}
/*
{
bool old_need_lock;
old_need_lock = mblock->need_lock;
@ -1173,6 +1174,7 @@ OUTER:
mblock, *reclaim_count, fast_mblock_free_count(mblock));
mblock->need_lock = old_need_lock;
}
*/
*ppFreelist = freelist;
return (freelist != NULL ? 0 : ENOENT);

View File

@ -46,7 +46,6 @@ void sorted_queue_push_ex(struct sorted_queue *sq, void *data, bool *notify)
{
struct fc_list_head *dlink;
struct fc_list_head *current;
int count = 0;
dlink = FC_SORTED_QUEUE_DLINK_PTR(sq, data);
PTHREAD_MUTEX_LOCK(&sq->lcp.lock);
@ -70,7 +69,6 @@ void sorted_queue_push_ex(struct sorted_queue *sq, void *data, bool *notify)
sq, current)) < 0)
{
current = current->prev;
++count;
}
fc_list_add_after(dlink, current);
*notify = false;