From: Minje Ahn Date: Thu, 4 Nov 2021 05:22:15 +0000 (+0900) Subject: [UTC][media-content][Non-ACR] Code cleanup X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a62e7a34a05902f40f1c5fc9df57101dbc08bc67;p=test%2Ftct%2Fnative%2Fapi.git [UTC][media-content][Non-ACR] Code cleanup Change-Id: I4755cd8b944b0683ecfa6069a74395a8b0c4be64 Signed-off-by: Minje Ahn --- diff --git a/src/utc/media-content/utc-media-audio.c b/src/utc/media-content/utc-media-audio.c index 96173faeb..2da09415c 100755 --- a/src/utc/media-content/utc-media-audio.c +++ b/src/utc/media-content/utc-media-audio.c @@ -29,15 +29,6 @@ static GMainLoop *g_loop = NULL; static media_content_error_e cb_result = MEDIA_CONTENT_ERROR_NONE; static media_content_error_e startup_ret = MEDIA_CONTENT_ERROR_NONE; -static bool __storage_device_supported_cb(int storage_id, storage_type_e type, storage_state_e state, const char *path, void *user_data) -{ - if (type == STORAGE_TYPE_INTERNAL) { - dir_path = strdup(path); - return false; - } - return true; -} - static void _scan_folder_cb(media_content_error_e error, void *user_data) { cb_result = error; @@ -80,7 +71,7 @@ void utc_media_audio_startup(void) g_audio = NULL; g_audio_dst = NULL; - if (storage_foreach_device_supported(__storage_device_supported_cb, NULL) != STORAGE_ERROR_NONE) + if (storage_get_root_directory(0, &dir_path) != STORAGE_ERROR_NONE) fprintf(stderr, "Startup error at %s:%d\n", __FILE__, __LINE__); ret = media_content_connect(); @@ -160,10 +151,7 @@ void utc_media_audio_cleanup(void) g_audio_dst = NULL; } - if (dir_path) { - free(dir_path); - dir_path = NULL; - } + FREE_MEMORY(dir_path); media_content_disconnect(); } diff --git a/src/utc/media-content/utc-media-playlist.c b/src/utc/media-content/utc-media-playlist.c index 9ac0f62b1..079486ab6 100755 --- a/src/utc/media-content/utc-media-playlist.c +++ b/src/utc/media-content/utc-media-playlist.c @@ -96,10 +96,8 @@ static bool playlist_cb(media_playlist_h playlist, void *user_data) media_playlist_get_name(g_playlist, &name); } - if (name) { - free(name); - name = NULL; - } + FREE_MEMORY(name); + return true; } @@ -186,11 +184,7 @@ void utc_media_playlist_startup(void) void utc_media_playlist_cleanup(void) { /* end of TC */ - - if (g_media_id != NULL) { - free(g_media_id); - g_media_id = NULL; - } + FREE_MEMORY(g_media_id); if (g_filter != NULL) { media_filter_destroy(g_filter); @@ -204,22 +198,10 @@ void utc_media_playlist_cleanup(void) media_playlist_delete_from_db(g_playlist_id); media_content_disconnect(); - if (img_path != NULL) { - free(img_path); - img_path = NULL; - } - if (playlist_path != NULL) { - free(playlist_path); - playlist_path = NULL; - } - if (create_path != NULL) { - free(create_path); - create_path = NULL; - } - if (copy_path != NULL) { - free(copy_path); - copy_path = NULL; - } + FREE_MEMORY(img_path); + FREE_MEMORY(playlist_path); + FREE_MEMORY(create_path); + FREE_MEMORY(copy_path); } /** @@ -270,10 +252,7 @@ int utc_media_playlist_insert_to_db_p(void) else ret = MEDIA_CONTENT_ERROR_INVALID_OPERATION; - if (name) { - free(name); - name = NULL; - } + FREE_MEMORY(name); assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); ret = media_playlist_get_playlist_id(g_playlist, &playlist_id); @@ -539,10 +518,8 @@ int utc_media_playlist_clone_p(void) if (strcmp(org_name, dst_name)) ret = MEDIA_CONTENT_ERROR_INVALID_OPERATION; - free(org_name); - org_name = NULL; - free(dst_name); - dst_name = NULL; + FREE_MEMORY(org_name); + FREE_MEMORY(dst_name); } else { ret = MEDIA_CONTENT_ERROR_INVALID_OPERATION; } @@ -645,12 +622,7 @@ int utc_media_playlist_get_name_n(void) char *name = NULL; ret = media_playlist_get_name(NULL, &name); - - if (name) { - free(name); - name = NULL; - } - + FREE_MEMORY(name); assert_eq(ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); return 0; @@ -669,12 +641,7 @@ int utc_media_playlist_get_name_p(void) char *name = NULL; ret = media_playlist_get_name(g_playlist, &name); - - if (name) { - free(name); - name = NULL; - } - + FREE_MEMORY(name); assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); return 0; @@ -781,10 +748,7 @@ static bool _set_name_cb(media_playlist_h playlist, void *user_data) ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; } - if (name) { - free(name); - name = NULL; - } + FREE_MEMORY(name); assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); @@ -1006,12 +970,7 @@ int utc_media_playlist_get_thumbnail_path_p(void) int ret = MEDIA_CONTENT_ERROR_NONE; ret = media_playlist_get_thumbnail_path(g_playlist, &thumbnail_path); - - if (thumbnail_path) { - free(thumbnail_path); - thumbnail_path = NULL; - } - + FREE_MEMORY(thumbnail_path); assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); return 0; @@ -1052,12 +1011,7 @@ static bool _set_thumbnail_path_cb(media_playlist_h playlist, void *user_data) ret = MEDIA_CONTENT_ERROR_DB_FAILED; } } - - if (get_thumb_path) { - free(get_thumb_path); - get_thumb_path = NULL; - } - + FREE_MEMORY(get_thumb_path); assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); return true; diff --git a/src/utc/media-content/utc-media-tag.c b/src/utc/media-content/utc-media-tag.c index 721e14bd0..f97be13fb 100755 --- a/src/utc/media-content/utc-media-tag.c +++ b/src/utc/media-content/utc-media-tag.c @@ -119,10 +119,8 @@ void utc_media_tag_cleanup(void) media_filter_destroy(g_filter); g_filter = NULL; } - if (g_media_id) { - free(g_media_id); - g_media_id = NULL; - } + FREE_MEMORY(g_media_id); + media_content_disconnect(); } @@ -135,7 +133,7 @@ static bool tag_cb(media_tag_h tag, void *user_data) if (name != NULL && strcmp(name, tag_name) == 0) { fprintf(stderr, " tag name : %s \n", name); - free(name); + FREE_MEMORY(name); } } @@ -557,10 +555,7 @@ static bool _set_name_cb(media_tag_h tag, void *user_data) ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; } - if (name) { - free(name); - name = NULL; - } + FREE_MEMORY(name); assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); @@ -656,12 +651,7 @@ int utc_media_tag_get_name_p(void) char *name = NULL; ret = media_tag_get_name(g_tag, &name); - - if (name) { - free(name); - name = NULL; - } - + FREE_MEMORY(name); assert_eq(ret, MEDIA_CONTENT_ERROR_NONE); return 0;