bugfixed: array_allocator_alloc MUST init the array
parent
1969fbba8d
commit
fafbbb557e
3
HISTORY
3
HISTORY
|
|
@ -1,4 +1,7 @@
|
||||||
|
|
||||||
|
Version 1.69 2023-08-02
|
||||||
|
* bugfixed: array_allocator_alloc MUST init the array
|
||||||
|
|
||||||
Version 1.68 2023-07-05
|
Version 1.68 2023-07-05
|
||||||
* sorted_queue.[hc]: pop_compare_func support argument
|
* sorted_queue.[hc]: pop_compare_func support argument
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@ VoidArray *array_allocator_alloc(ArrayAllocatorContext *ctx,
|
||||||
{
|
{
|
||||||
int alloc;
|
int alloc;
|
||||||
int bytes;
|
int bytes;
|
||||||
|
VoidArray *array;
|
||||||
|
|
||||||
if (target_count <= ctx->min_count) {
|
if (target_count <= ctx->min_count) {
|
||||||
alloc = ctx->min_count;
|
alloc = ctx->min_count;
|
||||||
|
|
@ -71,7 +72,11 @@ VoidArray *array_allocator_alloc(ArrayAllocatorContext *ctx,
|
||||||
}
|
}
|
||||||
|
|
||||||
bytes = sizeof(VoidArray) + alloc * ctx->element_size;
|
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,
|
VoidArray *array_allocator_realloc(ArrayAllocatorContext *ctx,
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,6 @@ extern "C" {
|
||||||
static inline void array_allocator_free(ArrayAllocatorContext *ctx,
|
static inline void array_allocator_free(ArrayAllocatorContext *ctx,
|
||||||
VoidArray *array)
|
VoidArray *array)
|
||||||
{
|
{
|
||||||
array->count = 0;
|
|
||||||
fast_allocator_free(&ctx->allocator, array);
|
fast_allocator_free(&ctx->allocator, array);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1163,6 +1163,7 @@ OUTER:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
{
|
{
|
||||||
bool old_need_lock;
|
bool old_need_lock;
|
||||||
old_need_lock = mblock->need_lock;
|
old_need_lock = mblock->need_lock;
|
||||||
|
|
@ -1173,6 +1174,7 @@ OUTER:
|
||||||
mblock, *reclaim_count, fast_mblock_free_count(mblock));
|
mblock, *reclaim_count, fast_mblock_free_count(mblock));
|
||||||
mblock->need_lock = old_need_lock;
|
mblock->need_lock = old_need_lock;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
*ppFreelist = freelist;
|
*ppFreelist = freelist;
|
||||||
return (freelist != NULL ? 0 : ENOENT);
|
return (freelist != NULL ? 0 : ENOENT);
|
||||||
|
|
|
||||||
|
|
@ -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 *dlink;
|
||||||
struct fc_list_head *current;
|
struct fc_list_head *current;
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
dlink = FC_SORTED_QUEUE_DLINK_PTR(sq, data);
|
dlink = FC_SORTED_QUEUE_DLINK_PTR(sq, data);
|
||||||
PTHREAD_MUTEX_LOCK(&sq->lcp.lock);
|
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)
|
sq, current)) < 0)
|
||||||
{
|
{
|
||||||
current = current->prev;
|
current = current->prev;
|
||||||
++count;
|
|
||||||
}
|
}
|
||||||
fc_list_add_after(dlink, current);
|
fc_list_add_after(dlink, current);
|
||||||
*notify = false;
|
*notify = false;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue