demo: Free found_group_list when inserting new groups in list
authorSaurav Babu <saurav.babu@samsung.com>
Wed, 24 Jan 2018 10:22:03 +0000 (15:52 +0530)
committersaerome.kim <saerome.kim@samsung.com>
Mon, 2 Jul 2018 10:38:47 +0000 (19:38 +0900)
Signed-off-by: Saurav Babu <saurav.babu@samsung.com>
capi/demo/comp-manager.c

index dbc44c1fd2136ed5bf5471725561c179d583060b..f660b091fe4207cd767cb2e627a5ecc51cb86731 100644 (file)
@@ -578,8 +578,8 @@ static int run_group_show(MManager *mm, struct menu_data *menu)
                if (!group) {
                        msgr("groups is null");
                        break;
-               }
-               companion_group_information_get_type(group, &type);
+               }
+               companion_group_information_get_type(group, &type);
                companion_group_information_get_uri_path(group, &uri);
                companion_group_information_get_resource_type(group, &rt);
                msgb("[%d] type: %s, URI: %s RT: %s", i+1, comp_group_type_to_string(type), uri, rt);
@@ -669,6 +669,11 @@ static int run_group_join(MManager *mm, struct menu_data *menu)
        return RET_SUCCESS;
 }
 
+static void _destroy_comp_group_info(gpointer data)
+{
+       companion_group_information_destroy((companion_group_h)data);
+}
+
 static int run_group_get_found(MManager *mm, struct menu_data *menu)
 {
        int ret;
@@ -683,7 +688,11 @@ static int run_group_get_found(MManager *mm, struct menu_data *menu)
                return RET_FAILURE;
        }
        msg(" - companion_group_get_found_groups() ret: [0x%X] [%s]", ret, comp_error_to_string(ret));
-       found_group_list = NULL;
+
+       if (found_group_list) {
+               g_list_free_full(found_group_list, _destroy_comp_group_info);
+               found_group_list = NULL;
+       }
 
        for (int i = 0; i < count; i++) {
                companion_group_type_e type;
@@ -716,11 +725,6 @@ void _group_finish_cb(int result, void *user_data)
        msgb("Find Group Finished = %d", result);
 }
 
-static void _destroy_comp_group_info(gpointer data)
-{
-       companion_group_information_destroy((companion_group_h)data);
-}
-
 static int run_group_find(MManager *mm, struct menu_data *menu)
 {
        int ret;