From 107826839d3196f27a66ed605322aa20ee93df67 Mon Sep 17 00:00:00 2001 From: "jiyong.min" Date: Tue, 18 Sep 2018 07:46:48 +0900 Subject: [PATCH] Add to destory Glist and search item by g_list_free_full Change-Id: I7ac83c7b228b3273d81743227a94c2475d754cf8 --- packaging/capi-media-controller.spec | 2 +- src/media_controller_metadata.c | 29 ++++++++++++++--------------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/packaging/capi-media-controller.spec b/packaging/capi-media-controller.spec index b982c2b..6e330af 100755 --- a/packaging/capi-media-controller.spec +++ b/packaging/capi-media-controller.spec @@ -1,6 +1,6 @@ Name: capi-media-controller Summary: A media controller library in Tizen Native API -Version: 0.1.72 +Version: 0.1.73 Release: 1 Group: Multimedia/API License: Apache-2.0 diff --git a/src/media_controller_metadata.c b/src/media_controller_metadata.c index a54c8c8..de5e69d 100755 --- a/src/media_controller_metadata.c +++ b/src/media_controller_metadata.c @@ -231,28 +231,27 @@ int mc_search_set_condition(mc_search_h search, mc_content_type_e content_type, return ret; } +void _destroy_search_list(gpointer data) +{ + mc_search_item_s *search_item = (mc_search_item_s*)data; + + if (search_item != NULL) { + MC_SAFE_FREE(search_item->search_keyword); + if (search_item->data != NULL) + bundle_free(search_item->data); + MC_SAFE_FREE(search_item); + } +} + int mc_search_destroy(mc_search_h search) { int ret = MEDIA_CONTROLLER_ERROR_NONE; media_controller_search_s *mc_search = (media_controller_search_s *)search; - mc_search_item_s *search_item = NULL; - int length = 0; - int idx = 0; mc_retvm_if(mc_search == NULL, MEDIA_CONTROLLER_ERROR_INVALID_PARAMETER, "search is NULL"); - length = g_list_length(mc_search->search_list); - - for (idx = 0; idx < length; idx++) { - search_item = (mc_search_item_s*)g_list_nth_data(mc_search->search_list, idx); - - if (search_item != NULL) { - MC_SAFE_FREE(search_item->search_keyword); - if (search_item->data != NULL) - bundle_free(search_item->data); - MC_SAFE_FREE(search_item); - } - } + g_list_free_full(mc_search->search_list, _destroy_search_list); + mc_search->search_list = NULL; MC_SAFE_FREE(mc_search); -- 2.7.4