From 1fe6a5fd0b9c0d2940182b4821ebe4c55709ee57 Mon Sep 17 00:00:00 2001 From: xianjimli Date: Thu, 17 Jan 2019 14:05:15 +0800 Subject: [PATCH] fix valgrind found errors --- src/base/assets_manager.c | 11 +---------- src/tkc/object.c | 2 +- tests/wstr_test.cc | 1 + 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/base/assets_manager.c b/src/base/assets_manager.c index 9432f28f8..9ffb90b80 100644 --- a/src/base/assets_manager.c +++ b/src/base/assets_manager.c @@ -223,6 +223,7 @@ asset_info_t* assets_manager_load(assets_manager_t* rm, asset_type_t type, const if (info != NULL) { assets_manager_add(rm, info); + asset_info_unref(info); } return info; @@ -380,18 +381,8 @@ ret_t assets_manager_clear_cache(assets_manager_t* rm, asset_type_t type) { } ret_t assets_manager_deinit(assets_manager_t* rm) { - uint32_t i = 0; - asset_info_t* iter = NULL; - asset_info_t** all = NULL; return_value_if_fail(rm != NULL, RET_BAD_PARAMS); - all = (asset_info_t**)(rm->assets.elms); - - for (i = 0; i < rm->assets.size; i++) { - iter = all[i]; - asset_info_destroy(iter); - } - TKMEM_FREE(rm->res_root); darray_deinit(&(rm->assets)); diff --git a/src/tkc/object.c b/src/tkc/object.c index 7257718c9..bb261f30a 100644 --- a/src/tkc/object.c +++ b/src/tkc/object.c @@ -47,7 +47,7 @@ static ret_t object_destroy(object_t* obj) { obj->vt = NULL; obj->ref_count = 0; emitter_deinit((emitter_t*)obj); - + TKMEM_FREE(obj->name); TKMEM_FREE(obj); return ret; diff --git a/tests/wstr_test.cc b/tests/wstr_test.cc index 819c4ec8e..497f3f3b0 100644 --- a/tests/wstr_test.cc +++ b/tests/wstr_test.cc @@ -306,6 +306,7 @@ TEST(WStr, push_int) { ASSERT_EQ(wstr_to_int(s, &v), RET_OK); ASSERT_EQ(v, 12345); s->size = 0; + wstr_reset(&str); wstr_init(&str1, 0); wstr_set(&str1, L"0123");