improve object_array

This commit is contained in:
lixianjing 2024-11-07 16:38:41 +08:00
parent b5b081429f
commit 8046e91439
3 changed files with 4 additions and 3 deletions

View File

@ -3,6 +3,7 @@
2024/11/07
* 修复locale_infos_unref接口释放info对象无法清除assets_manager上的野指针导致崩溃的问题(感谢雨欣提供补丁)
* 完善object_hash(感谢兆坤提供补丁)
* 完善object_array(感谢兆坤提供补丁)
* 统一是否可从名字中获取index的判断逻辑(感谢兆坤提供补丁)
2024/11/06

View File

@ -400,7 +400,7 @@ static ret_t object_array_find_props(tk_object_t* obj, tk_compare_t cmp, const v
value_t* iter = &o->props[i];
tk_snprintf(name, TK_NAME_LEN, "%" PRIu32, i);
value_copy(&(nv.value), iter);
if (0 == cmp(data, &nv)) {
if (0 == cmp(&nv, data)) {
ret = darray_push(matched, iter);
}
}
@ -422,7 +422,7 @@ static value_t* object_array_find_prop(tk_object_t* obj, tk_compare_t cmp, const
value_t* iter = &o->props[i];
tk_snprintf(name, TK_NAME_LEN, "%" PRIu32, i);
value_copy(&(nv.value), iter);
if (0 == cmp(ctx, &nv)) {
if (0 == cmp(&nv, ctx)) {
return iter;
}
}

View File

@ -768,7 +768,7 @@ TEST(ObjectArray, push_and_remove) {
TK_OBJECT_UNREF(obj);
}
static int is_even(const void* ctx, const void* data) {
static int is_even(const void* data, const void* ctx) {
const named_value_t* nv = (const named_value_t*)(data);
uint32_t num = value_uint32(&nv->value);
return (num % 2 == 0) ? 0 : -1;