Use g_ptr_array_new_with_free_func() instead 41/243641/1
authorMinje Ahn <minje.ahn@samsung.com>
Wed, 9 Sep 2020 01:49:33 +0000 (10:49 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Wed, 9 Sep 2020 01:49:33 +0000 (10:49 +0900)
Change-Id: I990e08600759902b888bba9957ba3036c551fb30
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
src/scanner-v2/media-scanner-scan-v2.c

index cc2d98f..f0c4ad0 100644 (file)
@@ -201,7 +201,7 @@ static int __msc_dir_scan_for_folder(sqlite3 *handle, const char *storage_id, ch
 
        new_start_path = g_strdup(start_path);
 
-       dir_array = g_ptr_array_new();
+       dir_array = g_ptr_array_new_with_free_func(g_free);
        g_ptr_array_add(dir_array, start_path);
 
        if (g_file_test(new_start_path, G_FILE_TEST_IS_DIR)) {
@@ -226,8 +226,7 @@ static int __msc_dir_scan_for_folder(sqlite3 *handle, const char *storage_id, ch
                ms_register_end(uid);
                ms_register_start(false, 0);
 
-               current_path = g_ptr_array_index(dir_array, 0);
-               g_ptr_array_remove_index(dir_array, 0);
+               current_path = g_ptr_array_steal_index(dir_array, 0);
 
                __msc_set_dir_scan_cur_path(current_path);
 
@@ -408,7 +407,7 @@ static int __msc_dir_scan_for_storage(sqlite3 *handle, const char *storage_id, c
 
        new_start_path = g_strdup(start_path);
 
-       dir_array = g_ptr_array_new();
+       dir_array = g_ptr_array_new_with_free_func(g_free);
        g_ptr_array_add(dir_array, start_path);
 
        if (ms_insert_folder(handle, storage_id, new_start_path, uid) != MS_MEDIA_ERR_NONE)
@@ -425,8 +424,7 @@ static int __msc_dir_scan_for_storage(sqlite3 *handle, const char *storage_id, c
 
                ms_register_start(false, 0);
 
-               current_path = g_ptr_array_index(dir_array, 0);
-               g_ptr_array_remove_index(dir_array, 0);
+               current_path = g_ptr_array_steal_index(dir_array, 0);
 
                __msc_set_storage_scan_cur_path(current_path);