Remove out of memory related code by using glib APIs 94/228894/17
authorhj kim <backto.kim@samsung.com>
Thu, 26 Mar 2020 08:05:15 +0000 (17:05 +0900)
committerhj kim <backto.kim@samsung.com>
Wed, 1 Apr 2020 07:52:56 +0000 (07:52 +0000)
glib's memory managed as below.
If any call to allocate memory fails, the application is terminated. This also means that there is no need to check if the call succeeded.

Change-Id: I01fb04132ed17b47091ba5925b2f49b618123b11

17 files changed:
src/media_audio.c
src/media_bookmark.c
src/media_content.c
src/media_db.c
src/media_face.c
src/media_filter.c
src/media_folder.c
src/media_group.c
src/media_image.c
src/media_info.c
src/media_playlist.c
src/media_pvr.c
src/media_storage.c
src/media_tag.c
src/media_uhd.c
src/media_util_private.c
src/media_video.c

index 0b8ead7..db02803 100644 (file)
@@ -22,17 +22,17 @@ int audio_meta_destroy(audio_meta_h audio)
        audio_meta_s *_audio = (audio_meta_s*)audio;
        content_retvm_if(_audio == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Audio handle is null");
 
-       SAFE_FREE(_audio->media_id);
-       SAFE_FREE(_audio->album);
-       SAFE_FREE(_audio->artist);
-       SAFE_FREE(_audio->album_artist);
-       SAFE_FREE(_audio->genre);
-       SAFE_FREE(_audio->composer);
-       SAFE_FREE(_audio->year);
-       SAFE_FREE(_audio->recorded_date);
-       SAFE_FREE(_audio->copyright);
-       SAFE_FREE(_audio->track_num);
-       SAFE_FREE(_audio);
+       g_free(_audio->media_id);
+       g_free(_audio->album);
+       g_free(_audio->artist);
+       g_free(_audio->album_artist);
+       g_free(_audio->genre);
+       g_free(_audio->composer);
+       g_free(_audio->year);
+       g_free(_audio->recorded_date);
+       g_free(_audio->copyright);
+       g_free(_audio->track_num);
+       g_free(_audio);
 
        return MEDIA_CONTENT_ERROR_NONE;
 }
@@ -40,10 +40,11 @@ int audio_meta_destroy(audio_meta_h audio)
 int audio_meta_clone(audio_meta_h *dst, audio_meta_h src)
 {
        audio_meta_s *_src = (audio_meta_s*)src;
-       content_retvm_if(_src == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Source handle is null");
 
-       audio_meta_s *_dst = (audio_meta_s*)calloc(1, sizeof(audio_meta_s));
-       content_retvm_if(_dst == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+       content_retip_if_fail(dst);
+       content_retip_if_fail(src);
+
+       audio_meta_s *_dst = g_new0(audio_meta_s, 1);
 
        _dst->media_id = g_strdup(_src->media_id);
        _dst->album = g_strdup(_src->album);
@@ -55,7 +56,6 @@ int audio_meta_clone(audio_meta_h *dst, audio_meta_h src)
        _dst->recorded_date = g_strdup(_src->recorded_date);
        _dst->copyright = g_strdup(_src->copyright);
        _dst->track_num = g_strdup(_src->track_num);
-
        _dst->bitrate = _src->bitrate;
        _dst->bitpersample = _src->bitpersample;
        _dst->samplerate = _src->samplerate;
@@ -70,7 +70,9 @@ int audio_meta_clone(audio_meta_h *dst, audio_meta_h src)
 int audio_meta_get_media_id(audio_meta_h audio, char **media_id)
 {
        audio_meta_s *_audio = (audio_meta_s*)audio;
-       content_retvm_if(!_audio || !media_id, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+       content_retip_if_fail(audio);
+       content_retip_if_fail(media_id);
 
        *media_id = g_strdup(_audio->media_id);
 
@@ -80,7 +82,9 @@ int audio_meta_get_media_id(audio_meta_h audio, char **media_id)
 int audio_meta_get_album(audio_meta_h audio, char **album)
 {
        audio_meta_s *_audio = (audio_meta_s*)audio;
-       content_retvm_if(!_audio || !album, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+       content_retip_if_fail(audio);
+       content_retip_if_fail(album);
 
        /*album can be empty string*/
        *album = g_strdup(_audio->album);
@@ -91,7 +95,9 @@ int audio_meta_get_album(audio_meta_h audio, char **album)
 int audio_meta_get_artist(audio_meta_h audio, char **artist)
 {
        audio_meta_s *_audio = (audio_meta_s*)audio;
-       content_retvm_if(!_audio || !artist, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+       content_retip_if_fail(audio);
+       content_retip_if_fail(artist);
 
        /*artist can be empty string*/
        *artist = g_strdup(_audio->artist);
@@ -102,7 +108,9 @@ int audio_meta_get_artist(audio_meta_h audio, char **artist)
 int audio_meta_get_album_artist(audio_meta_h audio, char **album_artist)
 {
        audio_meta_s *_audio = (audio_meta_s*)audio;
-       content_retvm_if(!_audio || !album_artist, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+       content_retip_if_fail(audio);
+       content_retip_if_fail(album_artist);
 
        /*album_artist can be empty string*/
        *album_artist = g_strdup(_audio->album_artist);
@@ -113,7 +121,9 @@ int audio_meta_get_album_artist(audio_meta_h audio, char **album_artist)
 int audio_meta_get_genre(audio_meta_h audio, char **genre)
 {
        audio_meta_s *_audio = (audio_meta_s*)audio;
-       content_retvm_if(!_audio || !genre, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+       content_retip_if_fail(audio);
+       content_retip_if_fail(genre);
 
        /*genre can be empty string*/
        *genre = g_strdup(_audio->genre);
@@ -124,7 +134,9 @@ int audio_meta_get_genre(audio_meta_h audio, char **genre)
 int audio_meta_get_composer(audio_meta_h audio, char **composer)
 {
        audio_meta_s *_audio = (audio_meta_s*)audio;
-       content_retvm_if(!_audio || !composer, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+       content_retip_if_fail(audio);
+       content_retip_if_fail(composer);
 
        /*composer can be empty string*/
        *composer = g_strdup(_audio->composer);
@@ -135,7 +147,9 @@ int audio_meta_get_composer(audio_meta_h audio, char **composer)
 int audio_meta_get_year(audio_meta_h audio, char **year)
 {
        audio_meta_s *_audio = (audio_meta_s*)audio;
-       content_retvm_if(!_audio || !year, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+       content_retip_if_fail(audio);
+       content_retip_if_fail(year);
 
        /*year can be empty string*/
        *year = g_strdup(_audio->year);
@@ -146,7 +160,9 @@ int audio_meta_get_year(audio_meta_h audio, char **year)
 int audio_meta_get_recorded_date(audio_meta_h audio, char **recorded_date)
 {
        audio_meta_s *_audio = (audio_meta_s*)audio;
-       content_retvm_if(!_audio || !recorded_date, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+       content_retip_if_fail(audio);
+       content_retip_if_fail(recorded_date);
 
        *recorded_date = g_strdup(_audio->recorded_date);
 
@@ -156,7 +172,9 @@ int audio_meta_get_recorded_date(audio_meta_h audio, char **recorded_date)
 int audio_meta_get_copyright(audio_meta_h audio, char **copyright)
 {
        audio_meta_s *_audio = (audio_meta_s*)audio;
-       content_retvm_if(!_audio || !copyright, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+       content_retip_if_fail(audio);
+       content_retip_if_fail(copyright);
 
        /*copyright can be empty string*/
        *copyright = g_strdup(_audio->copyright);
@@ -167,7 +185,9 @@ int audio_meta_get_copyright(audio_meta_h audio, char **copyright)
 int audio_meta_get_track_num(audio_meta_h audio, char **track_num)
 {
        audio_meta_s *_audio = (audio_meta_s*)audio;
-       content_retvm_if(!_audio || !track_num, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+       content_retip_if_fail(audio);
+       content_retip_if_fail(track_num);
 
        /*track_num can be empty string*/
        *track_num = g_strdup(_audio->track_num);
@@ -260,4 +280,4 @@ int audio_meta_update_to_db(audio_meta_h audio)
 
        return MEDIA_CONTENT_ERROR_NONE;
 }
-#endif
\ No newline at end of file
+#endif
index 1ed0018..81af59b 100755 (executable)
@@ -86,20 +86,21 @@ int media_bookmark_destroy(media_bookmark_h bookmark)
        media_bookmark_s *_bookmark = (media_bookmark_s *)bookmark;
        content_retvm_if(!_bookmark, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid paramter");
 
-       SAFE_FREE(_bookmark->media_id);
-       SAFE_FREE(_bookmark->thumbnail_path);
-       SAFE_FREE(_bookmark->name);
-       SAFE_FREE(_bookmark);
+       g_free(_bookmark->media_id);
+       g_free(_bookmark->thumbnail_path);
+       g_free(_bookmark->name);
+       g_free(_bookmark);
 
        return MEDIA_CONTENT_ERROR_NONE;
 }
 int media_bookmark_clone(media_bookmark_h *dst, media_bookmark_h src)
 {
        media_bookmark_s *_src = (media_bookmark_s *)src;
-       content_retvm_if(!_src, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid source");
 
-       media_bookmark_s *_dst = (media_bookmark_s *)calloc(1, sizeof(media_bookmark_s));
-       content_retvm_if(!_dst, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+       content_retip_if_fail(dst);
+       content_retip_if_fail(src);
+
+       media_bookmark_s *_dst = g_new0(media_bookmark_s, 1);
 
        _dst->bookmark_id = _src->bookmark_id;
        _dst->media_id = g_strdup(_src->media_id);
@@ -135,7 +136,9 @@ int media_bookmark_get_marked_time(media_bookmark_h bookmark, time_t* marked_tim
 int media_bookmark_get_thumbnail_path(media_bookmark_h bookmark, char **path)
 {
        media_bookmark_s *_bookmark = (media_bookmark_s *)bookmark;
-       content_retvm_if(!_bookmark || !path, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+       content_retip_if_fail(bookmark);
+       content_retip_if_fail(path);
 
        *path = g_strdup(_bookmark->thumbnail_path);
 
@@ -145,7 +148,9 @@ int media_bookmark_get_thumbnail_path(media_bookmark_h bookmark, char **path)
 int media_bookmark_get_name(media_bookmark_h bookmark, char **name)
 {
        media_bookmark_s *_bookmark = (media_bookmark_s *)bookmark;
-       content_retvm_if(!_bookmark || !name, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+       content_retip_if_fail(bookmark);
+       content_retip_if_fail(name);
 
        *name = g_strdup(_bookmark->name);
 
@@ -155,8 +160,10 @@ int media_bookmark_get_name(media_bookmark_h bookmark, char **name)
 int media_bookmark_set_name(media_bookmark_h bookmark, const char *name)
 {
        media_bookmark_s *_bookmark = (media_bookmark_s *)bookmark;
-       content_retvm_if(!_bookmark, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
 
+       content_retip_if_fail(bookmark);
+
+       g_free(_bookmark->name);
        _bookmark->name = g_strdup(STRING_VALID(name) ? name : MEDIA_CONTENT_EMPTY_STRING);
 
        return MEDIA_CONTENT_ERROR_NONE;
@@ -180,14 +187,12 @@ int media_bookmark_create(const char *media_id, time_t time, media_bookmark_h *b
 {
        int ret = MEDIA_CONTENT_ERROR_NONE;
 
-       content_retvm_if(!STRING_VALID(media_id), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid media_id");
-       content_retvm_if(!bookmark, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid bookmark");
+       content_retip_if_fail(bookmark);
 
        ret = __media_bookmark_check_media_id(media_id);
        content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "Not exist media_id");
 
-       media_bookmark_s *_bookmark = (media_bookmark_s *)calloc(1, sizeof(media_bookmark_s));
-       content_retvm_if(!_bookmark, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+       media_bookmark_s *_bookmark = g_new0(media_bookmark_s, 1);
 
        _bookmark->media_id = g_strdup(media_id);
        _bookmark->bookmark_id = -1;
@@ -201,8 +206,10 @@ int media_bookmark_create(const char *media_id, time_t time, media_bookmark_h *b
 int media_bookmark_set_thumbnail_path(media_bookmark_h bookmark, const char *path)
 {
        media_bookmark_s *_bookmark = (media_bookmark_s *)bookmark;
-       content_retvm_if(!_bookmark, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid bookmark");
 
+       content_retip_if_fail(bookmark);
+
+       g_free(_bookmark->thumbnail_path);
        _bookmark->thumbnail_path = g_strdup(path);
 
        return MEDIA_CONTENT_ERROR_NONE;
index da5b730..bc96f35 100644 (file)
@@ -351,7 +351,7 @@ void _media_content_scan_cb(media_request_result_s* result, void *user_data)
                        content_debug("end:User callback is being called now, result=%d", err);
                }
 
-               SAFE_FREE(cb_data);
+               g_free(cb_data);
        }
 #else
        if (cb_data && cb_data->callback) {
@@ -359,7 +359,7 @@ void _media_content_scan_cb(media_request_result_s* result, void *user_data)
                cb_data->callback(err, cb_data->user_data);
        }
 
-       SAFE_FREE(cb_data);
+       g_free(cb_data);
 #endif
 
        return;
@@ -393,7 +393,7 @@ void _media_content_scan_cb_v2(media_request_result_s* result, void *user_data)
        if ((result->request_type != MEDIA_REQUEST_SCAN_COMPLETE) &&
        (result->request_type != MEDIA_REQUEST_SCAN_PARTIAL) &&
        (result->request_type != MEDIA_RECURSIVE_START))
-               SAFE_FREE(cb_data);
+               g_free(cb_data);
 
        return;
 }
@@ -406,7 +406,8 @@ int media_content_scan_folder(const char *path, bool is_recursive, media_scan_co
        char repl_path[MAX_PATH_LEN] = {0, };
        ms_user_storage_type_e storage_type = MS_USER_STORAGE_INTERNAL;
 
-       content_retvm_if(!STRING_VALID(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
+       content_retip_if_fail(STRING_VALID(path));
+       content_retip_if_fail(callback);
 
        ret = _media_content_replace_path(path, repl_path);
        content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
@@ -436,8 +437,7 @@ int media_content_scan_folder(const char *path, bool is_recursive, media_scan_co
        }
 
        media_content_scan_cb_data *cb_data = NULL;
-       cb_data = (media_content_scan_cb_data *)malloc(sizeof(media_content_scan_cb_data));
-       content_retvm_if(cb_data == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+       cb_data = g_new0(media_content_scan_cb_data, 1);
 
        cb_data->callback = callback;
        cb_data->user_data = user_data;
@@ -445,7 +445,7 @@ int media_content_scan_folder(const char *path, bool is_recursive, media_scan_co
        ret = media_directory_scanning_async(repl_path, storage_id, is_recursive, _media_content_scan_cb, cb_data, _content_get_uid());
        if (ret != MS_MEDIA_ERR_NONE) {
                content_error("media_directory_scanning_async failed : %d", ret);
-               SAFE_FREE(cb_data);
+               g_free(cb_data);
        }
 
        return _content_error_capi(ret);
@@ -457,7 +457,9 @@ int media_content_scan_folder_v2(const char *path, bool is_recursive, media_scan
        int ret = MEDIA_CONTENT_ERROR_NONE;
        char storage_id[MEDIA_CONTENT_UUID_SIZE+1] = {0, };
 
-       content_retvm_if(!STRING_VALID(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path");
+       content_retip_if_fail(STRING_VALID(path));
+       content_retip_if_fail(callback);
+
        content_retvm_if(_media_util_is_ignorable_dir(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid folder path");
 
        ret = _media_content_check_dir(path);
@@ -465,8 +467,7 @@ int media_content_scan_folder_v2(const char *path, bool is_recursive, media_scan
        content_retvm_if(ret == MEDIA_CONTENT_ERROR_INVALID_PARAMETER, ret, "invalid path[%s]", path);
 
        media_content_scan_cb_data_v2* cb_data = NULL;
-       cb_data = (media_content_scan_cb_data_v2*)malloc(sizeof(media_content_scan_cb_data_v2));
-       content_retvm_if(cb_data == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+       cb_data = g_new0(media_content_scan_cb_data_v2, 1);
 
        cb_data->callback = callback;
        cb_data->user_data = user_data;
@@ -529,18 +530,17 @@ int media_content_add_db_updated_cb(media_content_db_update_cb callback, void *u
        int ret = MEDIA_CONTENT_ERROR_NONE;
        media_noti_cb_s *noti_info = NULL;
 
-       content_retvm_if(noti_handle == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "handle is NULL");
-       content_retvm_if(callback == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "callback is NULL");
+       content_retip_if_fail(callback);
+       content_retip_if_fail(noti_handle);
 
-       noti_info = (media_noti_cb_s *)calloc(1, sizeof(media_noti_cb_s));
-       content_retvm_if(noti_info == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "Failed to create noti info");
+       noti_info = g_new0(media_noti_cb_s, 1);
 
        noti_info->update_noti_cb = callback;
        noti_info->user_data = user_data;
 
        ret = media_db_update_subscribe((MediaNotiHandle*)noti_handle, _media_content_db_update_noti_cb, (void *)noti_info);
        if (ret != MS_MEDIA_ERR_NONE)
-               SAFE_FREE(noti_info);
+               g_free(noti_info);
 
        return _content_error_capi(ret);
 }
index 7b31cbc..6a37f5a 100755 (executable)
@@ -313,8 +313,8 @@ int _media_db_get_media_group_count(media_group_e group, filter_h filter, int *g
        }
 
        ret = _content_query_prepare(select_query, condition_query, option_query, &stmt);
-       SAFE_FREE(condition_query);
-       SAFE_FREE(option_query);
+       g_free(condition_query);
+       g_free(option_query);
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        if (sqlite3_step(stmt) == SQLITE_ROW)
@@ -355,19 +355,19 @@ int _media_db_get_media_group(media_group_e group, filter_h filter, media_group_
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        ret = _content_query_prepare(select_query, condition_query, option_query, &stmt);
-       SAFE_FREE(condition_query);
-       SAFE_FREE(option_query);
+       g_free(condition_query);
+       g_free(option_query);
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        while (sqlite3_step(stmt) == SQLITE_ROW) {
                name = g_strdup((const char *)sqlite3_column_text(stmt, 0));
 
                if (callback(name, user_data) == false) {
-                       SAFE_FREE(name);
+                       g_free(name);
                        break;
                }
 
-               SAFE_FREE(name);
+               g_free(name);
        }
 
        SQLITE3_FINALIZE(stmt);
@@ -418,20 +418,19 @@ int _media_db_get_media_group_and_count(media_group_e group, filter_h filter, me
                snprintf(group_query, sizeof(group_query), "GROUP BY %s", group_name);
 
        ret = _content_query_prepare(select_query, condition_query, group_query, &stmt);
-       SAFE_FREE(condition_query);
-       SAFE_FREE(option_query);
+       g_free(condition_query);
+       g_free(option_query);
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        while (sqlite3_step(stmt) == SQLITE_ROW) {
-               if (STRING_VALID((const char *)sqlite3_column_text(stmt, 0)))
-                       name = strdup((const char *)sqlite3_column_text(stmt, 0));
+               name = g_strdup((const char *)sqlite3_column_text(stmt, 0));
 
                if (callback(name, sqlite3_column_int(stmt, 1), user_data) == false) {
-                       SAFE_FREE(name);
+                       g_free(name);
                        break;
                }
 
-               SAFE_FREE(name);
+               g_free(name);
        }
 
        SQLITE3_FINALIZE(stmt);
@@ -580,11 +579,11 @@ int _media_db_get_media_group(media_group_e group, filter_h filter, media_group_
                name = g_strdup((const char *)sqlite3_column_text(stmt, 0));
 
                if (callback(name, user_data) == false) {
-                       SAFE_FREE(name);
+                       g_free(name);
                        break;
                }
 
-               SAFE_FREE(name);
+               g_free(name);
        }
 
        SQLITE3_FINALIZE(stmt);
@@ -617,18 +616,12 @@ int _media_db_get_album(filter_h filter, media_album_cb callback, void *user_dat
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        ret = _content_query_prepare(select_query, condition_query, option_query, &stmt);
-       SAFE_FREE(condition_query);
-       SAFE_FREE(option_query);
+       g_free(condition_query);
+       g_free(option_query);
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        while (sqlite3_step(stmt) == SQLITE_ROW) {
-               media_album_s *album = (media_album_s*)calloc(1, sizeof(media_album_s));
-
-               if (album == NULL) {
-                       content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                       SQLITE3_FINALIZE(stmt);
-                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-               }
+               media_album_s *album = g_new0(media_album_s, 1);
 
                album->album_id = sqlite3_column_int(stmt, 0);
                album->name = g_strdup((const char *)sqlite3_column_text(stmt, 1));
@@ -672,18 +665,12 @@ int _media_db_get_folder(filter_h filter, media_folder_cb callback, void *user_d
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        ret = _content_query_prepare(select_query, condition_query, option_query, &stmt);
-       SAFE_FREE(condition_query);
-       SAFE_FREE(option_query);
+       g_free(condition_query);
+       g_free(option_query);
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        while (sqlite3_step(stmt) == SQLITE_ROW) {
-               media_folder_s *_folder = (media_folder_s*)calloc(1, sizeof(media_folder_s));
-
-               if (_folder == NULL) {
-                       content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                       SQLITE3_FINALIZE(stmt);
-                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-               }
+               media_folder_s *_folder = g_new0(media_folder_s, 1);
 
                _folder->folder_id = g_strdup((const char *)sqlite3_column_text(stmt, 0));
                _folder->path = g_strdup((const char *)sqlite3_column_text(stmt, 1));
@@ -715,18 +702,12 @@ int _media_db_get_playlist(filter_h filter, media_playlist_cb callback, void *us
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        ret = _content_query_prepare(SELECT_PLAYLIST_LIST, condition_query, option_query, &stmt);
-       SAFE_FREE(condition_query);
-       SAFE_FREE(option_query);
+       g_free(condition_query);
+       g_free(option_query);
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        while (sqlite3_step(stmt) == SQLITE_ROW) {
-               media_playlist_s *_playlist = (media_playlist_s*)calloc(1, sizeof(media_playlist_s));
-
-               if (_playlist == NULL) {
-                       content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                       SQLITE3_FINALIZE(stmt);
-                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-               }
+               media_playlist_s *_playlist = g_new0(media_playlist_s, 1);
 
                _playlist->playlist_id = sqlite3_column_int(stmt, 0);
                _playlist->name = g_strdup((const char *)sqlite3_column_text(stmt, 1));
@@ -770,13 +751,7 @@ int _media_db_get_playlist_item(int playlist_id, filter_h filter, playlist_membe
                int playlist_member_id = 0;
                playlist_member_id = sqlite3_column_int(stmt, MEDIA_INFO_ITEM_MAX);     /*MEDIA_INFO_ITEM_MAX is pm_id*/
 
-               media_info_s *_media = (media_info_s*)calloc(1, sizeof(media_info_s));
-
-               if (_media == NULL) {
-                       content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                       SQLITE3_FINALIZE(stmt);
-                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-               }
+               media_info_s *_media = g_new0(media_info_s, 1);
 
                _media_info_item_get_detail(stmt, (media_info_h)_media);
 
@@ -819,13 +794,7 @@ int _media_db_get_tag(const char *media_id, filter_h filter, media_tag_cb callba
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        while (sqlite3_step(stmt) == SQLITE_ROW) {
-               media_tag_s *_tag = (media_tag_s*)calloc(1, sizeof(media_tag_s));
-
-               if (_tag == NULL) {
-                       content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                       SQLITE3_FINALIZE(stmt);
-                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-               }
+               media_tag_s *_tag = g_new0(media_tag_s, 1);
 
                _tag->tag_id = sqlite3_column_int(stmt, 0);
                _tag->name = g_strdup((const char *)sqlite3_column_text(stmt, 1));
@@ -878,18 +847,12 @@ int _media_db_get_bookmark(const char *media_id, filter_h filter, media_bookmark
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        ret = _content_query_prepare(select_query, condition_query, option_query, &stmt);
-       SAFE_FREE(condition_query);
-       SAFE_FREE(option_query);
+       g_free(condition_query);
+       g_free(option_query);
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        while (sqlite3_step(stmt) == SQLITE_ROW) {
-               media_bookmark_s *bookmark = (media_bookmark_s*)calloc(1, sizeof(media_bookmark_s));
-
-               if (bookmark == NULL) {
-                       content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                       SQLITE3_FINALIZE(stmt);
-                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-               }
+               media_bookmark_s *bookmark = g_new0(media_bookmark_s, 1);
 
                bookmark->bookmark_id = sqlite3_column_int(stmt, 0);
                bookmark->media_id = g_strdup((const char *)sqlite3_column_text(stmt, 1));
@@ -946,18 +909,12 @@ int _media_db_get_face(const char *media_id, filter_h filter, media_face_cb call
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        ret = _content_query_prepare(select_query, condition_query, option_query, &stmt);
-       SAFE_FREE(condition_query);
-       SAFE_FREE(option_query);
+       g_free(condition_query);
+       g_free(option_query);
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        while (sqlite3_step(stmt) == SQLITE_ROW) {
-               media_face_s *face = (media_face_s*)calloc(1, sizeof(media_face_s));
-
-               if (face == NULL) {
-                       content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                       SQLITE3_FINALIZE(stmt);
-                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-               }
+               media_face_s *face = g_new0(media_face_s, 1);
 
                face->face_id = sqlite3_column_int(stmt, 0);
                face->media_id = g_strdup((const char *)sqlite3_column_text(stmt, 1));
@@ -1023,8 +980,8 @@ int _media_db_get_group_item_count_by_id(int group_id, filter_h filter, group_li
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        ret = _content_query_prepare(select_query, condition_query, option_query, &stmt);
-       SAFE_FREE(condition_query);
-       SAFE_FREE(option_query);
+       g_free(condition_query);
+       g_free(option_query);
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        if (sqlite3_step(stmt) == SQLITE_ROW)
@@ -1164,8 +1121,8 @@ int _media_db_get_group_item_count(const char *group_name, filter_h filter, grou
        }
 
        ret = _content_query_prepare(select_query, condition_query, option_query, &stmt);
-       SAFE_FREE(condition_query);
-       SAFE_FREE(option_query);
+       g_free(condition_query);
+       g_free(option_query);
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        if (sqlite3_step(stmt) == SQLITE_ROW)
@@ -1237,17 +1194,12 @@ int _media_db_get_group_item_by_id(int group_id, filter_h filter, media_info_cb
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        ret = _content_query_prepare(select_query, condition_query, option_query, &stmt);
-       SAFE_FREE(condition_query);
-       SAFE_FREE(option_query);
+       g_free(condition_query);
+       g_free(option_query);
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        while (sqlite3_step(stmt) == SQLITE_ROW) {
-               media_info_s *item = (media_info_s*)calloc(1, sizeof(media_info_s));
-               if (item == NULL) {
-                       content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                       SQLITE3_FINALIZE(stmt);
-                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-               }
+               media_info_s *item = g_new0(media_info_s, 1);
 
                _media_info_item_get_detail(stmt, (media_info_h)item);
 
@@ -1316,17 +1268,12 @@ int _media_db_get_group_item(const char *group_name, filter_h filter, media_info
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        ret = _content_query_prepare(select_query, condition_query, option_query, &stmt);
-       SAFE_FREE(condition_query);
-       SAFE_FREE(option_query);
+       g_free(condition_query);
+       g_free(option_query);
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        while (sqlite3_step(stmt) == SQLITE_ROW) {
-               media_info_s *item = (media_info_s*)calloc(1, sizeof(media_info_s));
-               if (item == NULL) {
-                       content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                       SQLITE3_FINALIZE(stmt);
-                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-               }
+               media_info_s *item = g_new0(media_info_s, 1);
 
                _media_info_item_get_detail(stmt, (media_info_h)item);
 
@@ -1393,12 +1340,7 @@ int _media_db_get_group_item_by_union_select(const char *group_name, filter_h fi
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        while (sqlite3_step(stmt) == SQLITE_ROW) {
-               media_info_s *item = (media_info_s*)calloc(1, sizeof(media_info_s));
-               if (item == NULL) {
-                       content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                       SQLITE3_FINALIZE(stmt);
-                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-               }
+               media_info_s *item = g_new0(media_info_s, 1);
 
                _media_info_item_get_detail(stmt, (media_info_h)item);
 
@@ -1490,8 +1432,8 @@ int _media_db_get_media_group_item_count(const char *group_name, filter_h filter
        }
 
        ret = _content_query_prepare(select_query, condition_query, option_query, &stmt);
-       SAFE_FREE(condition_query);
-       SAFE_FREE(option_query);
+       g_free(condition_query);
+       g_free(option_query);
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        if (sqlite3_step(stmt) == SQLITE_ROW)
@@ -1540,17 +1482,12 @@ int _media_db_get_media_group_item(const char *group_name, filter_h filter, medi
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        ret = _content_query_prepare(select_query, condition_query, option_query, &stmt);
-       SAFE_FREE(condition_query);
-       SAFE_FREE(option_query);
+       g_free(condition_query);
+       g_free(option_query);
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        while (sqlite3_step(stmt) == SQLITE_ROW) {
-               media_info_s *item = (media_info_s*)calloc(1, sizeof(media_info_s));
-               if (item == NULL) {
-                       content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                       SQLITE3_FINALIZE(stmt);
-                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-               }
+               media_info_s *item = g_new0(media_info_s, 1);
 
                _media_info_item_get_detail(stmt, (media_info_h)item);
 
@@ -1578,18 +1515,12 @@ int _media_db_get_storage(filter_h filter, media_storage_cb callback, void *user
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        ret = _content_query_prepare(SELECT_STORAGE_LIST, condition_query, option_query, &stmt);
-       SAFE_FREE(condition_query);
-       SAFE_FREE(option_query);
+       g_free(condition_query);
+       g_free(option_query);
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        while (sqlite3_step(stmt) == SQLITE_ROW) {
-               media_storage_s *_storage = (media_storage_s*)calloc(1, sizeof(media_storage_s));
-
-               if (_storage == NULL) {
-                       content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                       SQLITE3_FINALIZE(stmt);
-                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-               }
+               media_storage_s *_storage = g_new0(media_storage_s, 1);
 
                _storage->storage_id = g_strdup((const char *)sqlite3_column_text(stmt, 0));
                _storage->storage_path = g_strdup((const char *)sqlite3_column_text(stmt, 1));
@@ -1658,17 +1589,12 @@ int _media_db_get_pvr_group_item(const char *group_name, filter_h filter, media_
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        ret = _content_query_prepare(select_query, condition_query, option_query, &stmt);
-       SAFE_FREE(condition_query);
-       SAFE_FREE(option_query);
+       g_free(condition_query);
+       g_free(option_query);
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        while (sqlite3_step(stmt) == SQLITE_ROW) {
-               media_pvr_s *item = (media_pvr_s*)calloc(1, sizeof(media_pvr_s));
-               if (item == NULL) {
-                       content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                       SQLITE3_FINALIZE(stmt);
-                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-               }
+               media_pvr_s *item = g_new0(media_pvr_s, 1);
 
                _media_pvr_item_get_detail(stmt, (media_pvr_h)item);
 
@@ -1740,113 +1666,53 @@ void _media_pvr_item_get_detail(sqlite3_stmt* stmt, media_pvr_h pvr)
 {
        media_pvr_s *_pvr = (media_pvr_s*)pvr;
 
-       if (STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_PVR_MEDIA_ID)))
-               _pvr->media_id = strdup((const char *)sqlite3_column_text(stmt, MEDIA_PVR_MEDIA_ID));
-
-       if (STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_PVR_STORAGE_ID)))
-               _pvr->storage_id = strdup((const char *)sqlite3_column_text(stmt, MEDIA_PVR_STORAGE_ID));
-
-       if (STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_PVR_PATH)))
-               _pvr->path = strdup((const char *)sqlite3_column_text(stmt, MEDIA_PVR_PATH));
-
+       _pvr->media_id = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_PVR_MEDIA_ID));
+       _pvr->storage_id = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_PVR_STORAGE_ID));
+       _pvr->path = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_PVR_PATH));
        _pvr->size = (unsigned long long)sqlite3_column_int64(stmt, MEDIA_PVR_SIZE);
-
        _pvr->duration = sqlite3_column_int(stmt, MEDIA_PVR_DURATION);
-
        _pvr->timezone = sqlite3_column_int(stmt, MEDIA_PVR_TIME_ZONE);
-
        _pvr->ptc = sqlite3_column_int(stmt, MEDIA_PVR_PTC);
-
        _pvr->major = sqlite3_column_int(stmt, MEDIA_PVR_MAJOR);
-
        _pvr->minor = sqlite3_column_int(stmt, MEDIA_PVR_MINOR);
-
        _pvr->channel_type = sqlite3_column_int(stmt, MEDIA_PVR_CHANNEL_TYPE);
-
        _pvr->service_profile = (unsigned int)sqlite3_column_int(stmt, MEDIA_PVR_SERVICE_PROFILE);
-
-       if (STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_PVR_CHANNEL_NAME)))
-               _pvr->channel_name = strdup((const char *)sqlite3_column_text(stmt, MEDIA_PVR_CHANNEL_NAME));
-
-       if (STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_PVR_CHANNEL_NUM)))
-               _pvr->channel_num = strdup((const char *)sqlite3_column_text(stmt, MEDIA_PVR_CHANNEL_NUM));
-
-       if (STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_PVR_PROGRAM_TITLE)))
-               _pvr->program_title = strdup((const char *)sqlite3_column_text(stmt, MEDIA_PVR_PROGRAM_TITLE));
-
+       _pvr->channel_name = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_PVR_CHANNEL_NAME));
+       _pvr->channel_num = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_PVR_CHANNEL_NUM));
+       _pvr->program_title = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_PVR_PROGRAM_TITLE));
        _pvr->program_num = sqlite3_column_int(stmt, MEDIA_PVR_PROGRAM_NUM);
-
-       if (STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_PVR_PROGRAM_CRID)))
-               _pvr->program_crid = strdup((const char *)sqlite3_column_text(stmt, MEDIA_PVR_PROGRAM_CRID));
-
-       if (STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_PVR_GUIDANCE)))
-               _pvr->guidance = strdup((const char *)sqlite3_column_text(stmt, MEDIA_PVR_GUIDANCE));
-
-       if (STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_PVR_SYNOPSIS)))
-               _pvr->synopsis = strdup((const char *)sqlite3_column_text(stmt, MEDIA_PVR_SYNOPSIS));
-
-       if (STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_PVR_GENRE)))
-               _pvr->genre = strdup((const char *)sqlite3_column_text(stmt, MEDIA_PVR_GENRE));
-
-       if (STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_PVR_LANGUAGE)))
-               _pvr->language = strdup((const char *)sqlite3_column_text(stmt, MEDIA_PVR_LANGUAGE));
-
-       if (STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_PVR_MODIFIED_MONTH)))
-               _pvr->modified_month = strdup((const char *)sqlite3_column_text(stmt, MEDIA_PVR_MODIFIED_MONTH));
-
-       if (STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_PVR_PRIVATE_DATA)))
-               _pvr->private_data = strdup((const char *)sqlite3_column_text(stmt, MEDIA_PVR_PRIVATE_DATA));
-
+       _pvr->program_crid = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_PVR_PROGRAM_CRID));
+       _pvr->guidance = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_PVR_GUIDANCE));
+       _pvr->synopsis = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_PVR_SYNOPSIS));
+       _pvr->genre = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_PVR_GENRE));
+       _pvr->language = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_PVR_LANGUAGE));
+       _pvr->modified_month = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_PVR_MODIFIED_MONTH));
+       _pvr->private_data = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_PVR_PRIVATE_DATA));
        _pvr->embargo_time = sqlite3_column_int(stmt, MEDIA_PVR_EMBARGO_TIME);
-
        _pvr->expiry_time = sqlite3_column_int(stmt, MEDIA_PVR_EXPIRY_TIME);
-
        _pvr->start_time = sqlite3_column_int(stmt, MEDIA_PVR_START_TIME);
-
        _pvr->program_start_time = sqlite3_column_int(stmt, MEDIA_PVR_PROGRAM_START_TIME);
-
        _pvr->program_end_time = sqlite3_column_int(stmt, MEDIA_PVR_PROGRAM_END_TIME);
-
        _pvr->program_date = sqlite3_column_int(stmt, MEDIA_PVR_PROGRAM_DATE);
-
        _pvr->parental_rating = sqlite3_column_int(stmt, MEDIA_PVR_PARENTAL_RATING);
-
        _pvr->timer_record = sqlite3_column_int(stmt, MEDIA_PVR_TIMER_RECORD);
-
        _pvr->series_record = sqlite3_column_int(stmt, MEDIA_PVR_SERIES_RECORD);
-
        _pvr->hd = sqlite3_column_int(stmt, MEDIA_PVR_HD);
-
        _pvr->subtitle = sqlite3_column_int(stmt, MEDIA_PVR_SUBTITLE);
-
        _pvr->ttx = sqlite3_column_int(stmt, MEDIA_PVR_TTX);
-
        _pvr->ad = sqlite3_column_int(stmt, MEDIA_PVR_AD);
-
        _pvr->hard_of_hearing_radio = sqlite3_column_int(stmt, MEDIA_PVR_HARDOF_HEARINGRADIO);
-
        _pvr->data_service = sqlite3_column_int(stmt, MEDIA_PVR_DATA_SERVICE);
-
        _pvr->content_lock = sqlite3_column_int(stmt, MEDIA_PVR_CONTENT_LOCK);
-
        _pvr->content_watch = sqlite3_column_int(stmt, MEDIA_PVR_CONTENT_WATCH);
-
        _pvr->has_audio_only = sqlite3_column_int(stmt, MEDIA_PVR_HAS_AUDIO_ONLY);
-
        _pvr->is_local_record = sqlite3_column_int(stmt, MEDIA_PVR_IS_LOCAL_RECORDED);
-
        _pvr->resolution = sqlite3_column_int(stmt, MEDIA_PVR_RESOLUTION);
-
        _pvr->aspectratio = sqlite3_column_int(stmt, MEDIA_PVR_ASPECTRATIO);
-
        _pvr->sports_type = sqlite3_column_int(stmt, MEDIA_PVR_SPORTS_TYPE);
-
        _pvr->guidance_length = sqlite3_column_int(stmt, MEDIA_PVR_GUIDANCE_LENGTH);
-
        _pvr->tvmode = sqlite3_column_int(stmt, MEDIA_PVR_TVMODE);
-
        _pvr->play_count = sqlite3_column_int(stmt, MEDIA_PVR_PLAY_COUNT);
-
        _pvr->highlight = sqlite3_column_int(stmt, MEDIA_PVR_HIGHLIGHT);
 
        return;
@@ -1870,18 +1736,12 @@ int _media_db_get_pvr(filter_h filter, media_pvr_cb callback, void *user_data)
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        ret = _content_query_prepare(select_query, condition_query, option_query, &stmt);
-       SAFE_FREE(condition_query);
-       SAFE_FREE(option_query);
+       g_free(condition_query);
+       g_free(option_query);
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        while (sqlite3_step(stmt) == SQLITE_ROW) {
-               media_pvr_s *_pvr = (media_pvr_s*)calloc(1, sizeof(media_pvr_s));
-
-               if (_pvr == NULL) {
-                       content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                       SQLITE3_FINALIZE(stmt);
-                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-               }
+               media_pvr_s *_pvr = g_new0(media_pvr_s, 1);
 
                _media_pvr_item_get_detail(stmt, (media_pvr_h)_pvr);
 
@@ -1918,29 +1778,14 @@ void _media_uhd_item_get_detail(sqlite3_stmt* stmt, media_uhd_h uhd)
 {
        media_uhd_s *_uhd = (media_uhd_s*)uhd;
 
-       if (STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_UHD_MEDIA_ID)))
-               _uhd->media_id = strdup((const char *)sqlite3_column_text(stmt, MEDIA_UHD_MEDIA_ID));
-
-       if (STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_UHD_STORAGE_ID)))
-               _uhd->storage_id = strdup((const char *)sqlite3_column_text(stmt, MEDIA_UHD_STORAGE_ID));
-
-       if (STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_UHD_PATH)))
-               _uhd->path = strdup((const char *)sqlite3_column_text(stmt, MEDIA_UHD_PATH));
-
+       _uhd->media_id = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_UHD_MEDIA_ID));
+       _uhd->storage_id = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_UHD_STORAGE_ID));
+       _uhd->path = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_UHD_PATH));
        _uhd->size = (unsigned long long)sqlite3_column_int64(stmt, MEDIA_UHD_SIZE);
-
-       if (STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_UHD_CONTENT_ID)))
-               _uhd->content_id = strdup((const char *)sqlite3_column_text(stmt, MEDIA_UHD_CONTENT_ID));
-
-       if (STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_UHD_CONTENT_TITLE)))
-               _uhd->content_title = strdup((const char *)sqlite3_column_text(stmt, MEDIA_UHD_CONTENT_TITLE));
-
-       if (STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_UHD_FILE_NAME)))
-               _uhd->file_name = strdup((const char *)sqlite3_column_text(stmt, MEDIA_UHD_FILE_NAME));
-
-       if (STRING_VALID((const char *)sqlite3_column_text(stmt, MEDIA_UHD_RELEASE_DATE)))
-               _uhd->release_date = strdup((const char *)sqlite3_column_text(stmt, MEDIA_UHD_RELEASE_DATE));
-
+       _uhd->content_id = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_UHD_CONTENT_ID));
+       _uhd->content_title = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_UHD_CONTENT_TITLE));
+       _uhd->file_name = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_UHD_FILE_NAME));
+       _uhd->release_date = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_UHD_RELEASE_DATE));
        _uhd->modified_time = sqlite3_column_int(stmt, MEDIA_UHD_MODIFIED_TIME);
        _uhd->played_position = sqlite3_column_int(stmt, MEDIA_UHD_PLAYED_POSITION);
        _uhd->sub_type = sqlite3_column_int(stmt, MEDIA_UHD_SUB_TYPE);
@@ -1967,18 +1812,12 @@ int _media_db_get_uhd(filter_h filter, media_uhd_cb callback, void *user_data)
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        ret = _content_query_prepare(select_query, condition_query, option_query, &stmt);
-       SAFE_FREE(condition_query);
-       SAFE_FREE(option_query);
+       g_free(condition_query);
+       g_free(option_query);
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        while (sqlite3_step(stmt) == SQLITE_ROW) {
-               media_uhd_s *_uhd = (media_uhd_s*)calloc(1, sizeof(media_uhd_s));
-
-               if (_uhd == NULL) {
-                       content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                       SQLITE3_FINALIZE(stmt);
-                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-               }
+               media_uhd_s *_uhd = g_new0(media_uhd_s, 1);
 
                _media_uhd_item_get_detail(stmt, (media_uhd_h)_uhd);
 
index b198126..89bc029 100755 (executable)
@@ -50,9 +50,9 @@ int media_face_destroy(media_face_h face)
 
        content_retvm_if(face == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid handle");
 
-       SAFE_FREE(_face->media_id);
-       SAFE_FREE(_face->face_tag);
-       SAFE_FREE(_face);
+       g_free(_face->media_id);
+       g_free(_face->face_tag);
+       g_free(_face);
 
        return MEDIA_CONTENT_ERROR_NONE;
 }
@@ -61,35 +61,19 @@ int media_face_clone(media_face_h *dst, media_face_h src)
 {
        media_face_s *_src = (media_face_s*)src;
 
-       content_retvm_if(src == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid src handle");
+       content_retip_if_fail(dst);
+       content_retip_if_fail(src);
 
-       media_face_s *_dst = (media_face_s *)calloc(1, sizeof(media_face_s));
-       content_retvm_if(_dst == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-
-       if (STRING_VALID(_src->media_id)) {
-               _dst->media_id = strdup(_src->media_id);
-               if (_dst->media_id == NULL) {
-                       media_face_destroy((media_face_h)_dst);
-                       content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-               }
-       }
+       media_face_s *_dst = g_new0(media_face_s, 1);
 
+       _dst->media_id = g_strdup(_src->media_id);
        _dst->face_id = _src->face_id;
        _dst->face_rect_x = _src->face_rect_x;
        _dst->face_rect_y = _src->face_rect_y;
        _dst->face_rect_w = _src->face_rect_w;
        _dst->face_rect_h = _src->face_rect_h;
        _dst->orientation = _src->orientation;
-
-       if (STRING_VALID(_src->face_tag)) {
-               _dst->face_tag = strdup(_src->face_tag);
-               if (_dst->face_tag == NULL) {
-                       media_face_destroy((media_face_h)_dst);
-                       content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-               }
-       }
+       _dst->face_tag = g_strdup(_src->face_tag);
 
        *dst = (media_face_h)_dst;
 
@@ -101,21 +85,18 @@ static void __media_face_convert_itoa(int face_id, char **face_strid)
        char buf[MAX_SIZE] = {0, };
 
        snprintf(buf, MAX_SIZE, "%d", face_id);
-       *face_strid = strndup(buf, strlen(buf));
+       *face_strid = g_strndup(buf, strlen(buf));
 }
 
 int media_face_get_face_id(media_face_h face, char **face_id)
 {
        media_face_s* _face = (media_face_s*)face;
 
-       content_retvm_if(face == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid handle");
+       content_retip_if_fail(face);
+       content_retip_if_fail(face_id);
 
-       if (_face->face_id > 0) {
+       if (_face->face_id > 0)
                __media_face_convert_itoa(_face->face_id, face_id);
-               content_retvm_if(*face_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "Out of memory");
-       } else {
-               *face_id = NULL;
-       }
 
        return MEDIA_CONTENT_ERROR_NONE;
 }
@@ -124,14 +105,10 @@ int media_face_get_media_id(media_face_h face, char **media_id)
 {
        media_face_s* _face = (media_face_s*)face;
 
-       content_retvm_if(face == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid handle");
+       content_retip_if_fail(face);
+       content_retip_if_fail(media_id);
 
-       if (STRING_VALID(_face->media_id)) {
-               *media_id = strdup(_face->media_id);
-               content_retvm_if(*media_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "Out of memory");
-       } else {
-               *media_id = NULL;
-       }
+       *media_id = g_strdup(_face->media_id);
 
        return MEDIA_CONTENT_ERROR_NONE;
 }
@@ -167,14 +144,10 @@ int media_face_get_tag(media_face_h face, char **tag)
 {
        media_face_s* _face = (media_face_s*)face;
 
-       content_retvm_if(face == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid handle");
+       content_retip_if_fail(face);
+       content_retip_if_fail(tag);
 
-       if (STRING_VALID(_face->face_tag)) {
-               *tag = strdup(_face->face_tag);
-               content_retvm_if(*tag == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "Out of memory");
-       } else {
-               *tag = NULL;
-       }
+       *tag = g_strdup(_face->face_tag);
 
        return MEDIA_CONTENT_ERROR_NONE;
 }
@@ -183,16 +156,14 @@ int media_face_create(const char *media_id, media_face_h *face)
 {
        int ret = MEDIA_CONTENT_ERROR_NONE;
 
-       content_retvm_if(!STRING_VALID(media_id), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid media_id");
-       content_retvm_if(face == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid handle");
+       content_retip_if_fail(face);
 
        ret = __media_face_check_media_id(media_id);
        content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "media_id does not exist or is not an image");
 
-       media_face_s* _face = calloc(1, sizeof(media_face_s));
-       content_retvm_if(_face == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "Out of memory");
+       media_face_s* _face = g_new0(media_face_s, 1);
 
-       _face->media_id = strdup(media_id);
+       _face->media_id = g_strdup(media_id);
 
        *face = (media_face_h)_face;
 
@@ -230,12 +201,10 @@ int media_face_set_tag(media_face_h face, const char *tag)
 {
        media_face_s* _face = (media_face_s*)face;
 
-       content_retvm_if(face == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid handle");
+       content_retip_if_fail(face);
 
-       if (STRING_VALID(tag))
-               _face->face_tag = strdup(tag);
-       else
-               _face->face_tag = NULL;
+       g_free(_face->face_tag);
+       _face->face_tag = g_strdup(tag);
 
        return MEDIA_CONTENT_ERROR_NONE;
 }
index fe498e0..65c44c2 100755 (executable)
@@ -150,10 +150,9 @@ int media_filter_create(filter_h *filter)
 {
        int ret = MEDIA_CONTENT_ERROR_NONE;
 
-       content_retvm_if(filter == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid filter");
+       content_retip_if_fail(filter);
 
-       filter_s *_filter = (filter_s *)calloc(1, sizeof(filter_s));
-       content_retvm_if(_filter == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+       filter_s *_filter = g_new0(filter_s, 1);
 
        _filter->storage_id = NULL;
        _filter->condition = NULL;
@@ -176,10 +175,10 @@ int media_filter_destroy(filter_h filter)
        filter_s *_filter = (filter_s *)filter;
        content_retvm_if(!_filter, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid filter");
 
-       SAFE_FREE(_filter->storage_id);
-       SAFE_FREE(_filter->condition);
-       SAFE_FREE(_filter->order_keyword);
-       SAFE_FREE(_filter);
+       g_free(_filter->storage_id);
+       g_free(_filter->condition);
+       g_free(_filter->order_keyword);
+       g_free(_filter);
 
        return MEDIA_CONTENT_ERROR_NONE;
 }
@@ -204,7 +203,7 @@ int media_filter_set_condition(filter_h filter, const char *condition, media_con
        content_retvm_if(!__check_collate_type(collate_type), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid collate_type");
 
        _filter->is_full_condition = false;
-       SAFE_FREE(_filter->condition);
+       g_free(_filter->condition);
 
        _filter->condition = _media_content_replace_path_in_condition(condition);
 
@@ -227,13 +226,15 @@ int media_filter_set_condition(filter_h filter, const char *condition, media_con
 int media_filter_set_order(filter_h filter, media_content_order_e order_type, const char *order_keyword, media_content_collation_e collate_type)
 {
        filter_s *_filter = (filter_s *)filter;
-       content_retvm_if(!_filter, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid filter");
-       content_retvm_if(!STRING_VALID(order_keyword), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid order_keyword");
-       content_retvm_if(!__check_order_type(order_type), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid order_type");
-       content_retvm_if(!__check_collate_type(collate_type), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid collate_type");
+
+       content_retip_if_fail(filter);
+       content_retip_if_fail(STRING_VALID(order_keyword));
+       content_retip_if_fail(__check_order_type(order_type));
+       content_retip_if_fail(__check_collate_type(collate_type));
 
        _filter->is_full_order = false;
-       SAFE_FREE(_filter->order_keyword);
+
+       g_free(_filter->order_keyword);
 
        _filter->order_keyword = g_strdup(order_keyword);
        _filter->order_type = order_type;
@@ -246,11 +247,13 @@ int media_filter_set_storage(filter_h filter, const char *storage_id)
 {
        content_warn("DEPRECATION WARNING: media_filter_set_storage() is deprecated and will be removed from next release. Use media_filter_set_condition() with MEDIA_PATH keyword instead.");
        filter_s *_filter = (filter_s *)filter;
-       content_retvm_if(!_filter || !STRING_VALID(storage_id), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
 
-       SAFE_FREE(_filter->storage_id);
+       content_retip_if_fail(filter);
+       content_retip_if_fail(STRING_VALID(storage_id));
 
+       g_free(_filter->storage_id);
        _filter->storage_id = g_strdup(storage_id);
+
        content_sec_debug("storage_id : %s", _filter->storage_id);
 
        return MEDIA_CONTENT_ERROR_NONE;
@@ -270,9 +273,10 @@ int media_filter_get_offset(filter_h filter, int *offset, int *count)
 int media_filter_get_condition(filter_h filter, char **condition, media_content_collation_e *collate_type)
 {
        filter_s *_filter = (filter_s *)filter;
-       content_retvm_if(!_filter, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid _filter");
-       content_retvm_if(!condition, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid condition");
-       content_retvm_if(!collate_type, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid collate_type");
+
+       content_retip_if_fail(filter);
+       content_retip_if_fail(condition);
+       content_retip_if_fail(collate_type);
 
        if (!_filter->is_full_condition)
                *condition = g_strdup(_filter->condition);
@@ -285,8 +289,11 @@ int media_filter_get_condition(filter_h filter, char **condition, media_content_
 int media_filter_get_order(filter_h filter, media_content_order_e *order_type, char **order_keyword, media_content_collation_e *collate_type)
 {
        filter_s *_filter = (filter_s *)filter;
-       content_retvm_if(!_filter || !order_type, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
-       content_retvm_if(!order_keyword || !collate_type, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+       content_retip_if_fail(filter);
+       content_retip_if_fail(order_type);
+       content_retip_if_fail(order_keyword);
+       content_retip_if_fail(collate_type);
 
        if (!_filter->is_full_order)
                *order_keyword = g_strdup(_filter->order_keyword);
@@ -301,7 +308,9 @@ int media_filter_get_storage(filter_h filter, char **storage_id)
 {
        content_warn("DEPRECATION WARNING: media_filter_get_storage() is deprecated and will be removed from next release.");
        filter_s *_filter = (filter_s *)filter;
-       content_retvm_if(!_filter || !storage_id, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+       content_retip_if_fail(filter);
+       content_retip_if_fail(storage_id);
 
        *storage_id = g_strdup(_filter->storage_id);
 
@@ -314,7 +323,8 @@ int media_filter_set_condition_v2(filter_h filter, const char *condition)
        content_retvm_if(!_filter || !STRING_VALID(condition), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
 
        _filter->is_full_condition = true;
-       SAFE_FREE(_filter->condition);
+
+       g_free(_filter->condition);
 
        /* FIXME
                If an error is occured in _media_content_replace_path_in_condition(),
@@ -334,7 +344,9 @@ int media_filter_set_condition_v2(filter_h filter, const char *condition)
 int media_filter_get_condition_v2(filter_h filter, char **condition)
 {
        filter_s *_filter = (filter_s *)filter;
-       content_retvm_if(!_filter || !condition, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+       content_retip_if_fail(filter);
+       content_retip_if_fail(condition);
 
        if (_filter->is_full_condition)
                *condition = g_strdup(_filter->condition);
@@ -345,11 +357,13 @@ int media_filter_get_condition_v2(filter_h filter, char **condition)
 int media_filter_set_order_v2(filter_h filter, const char *order)
 {
        filter_s *_filter = (filter_s *)filter;
-       content_retvm_if(!_filter || !STRING_VALID(order), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+       content_retip_if_fail(filter);
+       content_retip_if_fail(STRING_VALID(order));
 
        _filter->is_full_order = true;
-       SAFE_FREE(_filter->order_keyword);
 
+       g_free(_filter->order_keyword);
        _filter->order_keyword = g_strdup(order);
 
        return MEDIA_CONTENT_ERROR_NONE;
@@ -358,7 +372,9 @@ int media_filter_set_order_v2(filter_h filter, const char *order)
 int media_filter_get_order_v2(filter_h filter, char **order)
 {
        filter_s *_filter = (filter_s *)filter;
-       content_retvm_if(!_filter || !order, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+       content_retip_if_fail(filter);
+       content_retip_if_fail(order);
 
        if (_filter->is_full_order)
                *order = g_strdup(_filter->order_keyword);
index 96242c8..9137645 100755 (executable)
@@ -135,12 +135,13 @@ int media_folder_destroy(media_folder_h folder)
 {
        int ret = MEDIA_CONTENT_ERROR_NONE;
        media_folder_s *_folder = (media_folder_s*)folder;
+
        if (_folder) {
-               SAFE_FREE(_folder->path);
-               SAFE_FREE(_folder->name);
-               SAFE_FREE(_folder->folder_id);
-               SAFE_FREE(_folder->storage_uuid);
-               SAFE_FREE(_folder);
+               g_free(_folder->path);
+               g_free(_folder->name);
+               g_free(_folder->folder_id);
+               g_free(_folder->storage_uuid);
+               g_free(_folder);
                ret = MEDIA_CONTENT_ERROR_NONE;
        } else {
                content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
@@ -151,126 +152,58 @@ int media_folder_destroy(media_folder_h folder)
 }
 int media_folder_clone(media_folder_h *dst, media_folder_h src)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_folder_s *_src = (media_folder_s*)src;
 
-       if (_src != NULL) {
-               media_folder_s *_dst = (media_folder_s*)calloc(1, sizeof(media_folder_s));
-               content_retvm_if(_dst == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+       content_retip_if_fail(dst);
+       content_retip_if_fail(src);
 
-               if (STRING_VALID(_src->folder_id)) {
-                       _dst->folder_id = strdup(_src->folder_id);
-                       if (_dst->folder_id == NULL) {
-                               SAFE_FREE(_dst);
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               }
+       media_folder_s *_dst = g_new0(media_folder_s, 1);
 
-               if (STRING_VALID(_src->name)) {
-                       _dst->name = strdup(_src->name);
-                       if (_dst->name == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               media_folder_destroy((media_folder_h)_dst);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               }
-
-               if (STRING_VALID(_src->path)) {
-                       _dst->path = strdup(_src->path);
-                       if (_dst->path == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               media_folder_destroy((media_folder_h)_dst);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               }
+       _dst->folder_id = g_strdup(_src->folder_id);
+       _dst->name = g_strdup(_src->name);
+       _dst->path = g_strdup(_src->path);
+       _dst->storage_uuid = g_strdup(_src->storage_uuid);
+       _dst->storage_type = _src->storage_type;
 
-               if (STRING_VALID(_src->storage_uuid)) {
-                       _dst->storage_uuid = strdup(_src->storage_uuid);
-                       if (_dst->storage_uuid == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               media_folder_destroy((media_folder_h)_dst);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               }
-
-               _dst->storage_type = _src->storage_type;
-
-               *dst = (media_folder_h)_dst;
-
-               ret = MEDIA_CONTENT_ERROR_NONE;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       *dst = (media_folder_h)_dst;
 
-       return ret;
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_folder_get_folder_id(media_folder_h folder, char **folder_id)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_folder_s *_folder = (media_folder_s*)folder;
 
-       if (_folder) {
-               if (STRING_VALID(_folder->folder_id)) {
-                       *folder_id = strdup(_folder->folder_id);
-                       content_retvm_if(*folder_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-               } else {
-                       *folder_id = NULL;
-               }
-               ret = MEDIA_CONTENT_ERROR_NONE;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       content_retip_if_fail(folder);
+       content_retip_if_fail(folder_id);
 
-       return ret;
+       *folder_id = g_strdup(_folder->folder_id);
+
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_folder_get_path(media_folder_h folder, char **path)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_folder_s *_folder = (media_folder_s*)folder;
 
-       if (_folder) {
-               if (STRING_VALID(_folder->path)) {
-                       *path = strdup(_folder->path);
-                       content_retvm_if(*path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-               } else {
-                       *path = NULL;
-               }
-               ret = MEDIA_CONTENT_ERROR_NONE;
+       content_retip_if_fail(folder);
+       content_retip_if_fail(path);
 
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
-
-       return ret;
+       *path = g_strdup(_folder->path);
 
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_folder_get_name(media_folder_h folder, char **name)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_folder_s *_folder = (media_folder_s*)folder;
 
-       if (_folder) {
-               if (STRING_VALID(_folder->name)) {
-                       *name = strdup(_folder->name);
-                       content_retvm_if(*name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-               } else {
-                       *name = NULL;
-               }
-               ret = MEDIA_CONTENT_ERROR_NONE;
+       content_retip_if_fail(folder);
+       content_retip_if_fail(name);
 
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       *name = g_strdup(_folder->name);
 
-       return ret;
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_folder_get_storage_type(media_folder_h folder, media_content_storage_e* storage_type)
@@ -292,25 +225,15 @@ int media_folder_get_storage_type(media_folder_h folder, media_content_storage_e
 
 int media_folder_get_storage_id(media_folder_h folder, char **storage_id)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        content_warn("DEPRECATION WARNING: media_folder_get_storage_id() is deprecated and will be removed from next release.");
        media_folder_s *_folder = (media_folder_s*)folder;
 
-       if (_folder) {
-               if (STRING_VALID(_folder->storage_uuid)) {
-                       *storage_id = strdup(_folder->storage_uuid);
-                       content_retvm_if(*storage_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-               } else {
-                       *storage_id = NULL;
-               }
-               ret = MEDIA_CONTENT_ERROR_NONE;
+       content_retip_if_fail(folder);
+       content_retip_if_fail(storage_id);
 
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       *storage_id = g_strdup(_folder->storage_uuid);
 
-       return ret;
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_folder_get_folder_from_db(const char *folder_id, media_folder_h *folder)
@@ -320,10 +243,8 @@ int media_folder_get_folder_from_db(const char *folder_id, media_folder_h *folde
        char select_query[DEFAULT_QUERY_SIZE] = {0, };
        media_folder_s *_folder = NULL;
 
-       if (!STRING_VALID(folder_id)) {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       content_retip_if_fail(STRING_VALID(folder_id));
+       content_retip_if_fail(folder);
 
        snprintf(select_query, sizeof(select_query), SELECT_FOLDER_FROM_FOLDER, folder_id);
 
@@ -331,12 +252,7 @@ int media_folder_get_folder_from_db(const char *folder_id, media_folder_h *folde
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        if (sqlite3_step(stmt) == SQLITE_ROW) {
-               _folder = (media_folder_s*)calloc(1, sizeof(media_folder_s));
-               if (_folder == NULL) {
-                       content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                       SQLITE3_FINALIZE(stmt);
-                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-               }
+               _folder = g_new0(media_folder_s, 1);
 
                _folder->folder_id = g_strdup(folder_id);
                _folder->path = g_strdup((const char *)sqlite3_column_text(stmt, 0));
@@ -399,17 +315,15 @@ int media_folder_set_name(media_folder_h folder, const char *name)
                        snprintf(new_folder_path, sizeof(new_folder_path), "%s/%s", folder_path, name);
                        content_sec_debug("New Path : %s", new_folder_path);
 
-                       SAFE_FREE(g_src_path);
-                       g_src_path = strdup(repl_path);
+                       g_free(g_src_path);
+                       g_src_path = g_strdup(repl_path);
 
-                       SAFE_FREE(_folder->path);
-                       SAFE_FREE(_folder->name);
-                       SAFE_FREE(folder_path);
+                       g_free(_folder->path);
+                       g_free(_folder->name);
+                       g_free(folder_path);
 
-                       _folder->path = strdup(new_folder_path);
-                       content_retvm_if(_folder->path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-                       _folder->name = strdup(name);
-                       content_retvm_if(_folder->name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+                       _folder->path = g_strdup(new_folder_path);
+                       _folder->name = g_strdup(name);
                } else {
                        content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
                        ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
index e44a480..f3f1d12 100755 (executable)
@@ -80,8 +80,8 @@ int media_album_get_album_from_db(int album_id, media_album_h *album)
        sqlite3_stmt *stmt = NULL;
        char select_query[DEFAULT_QUERY_SIZE] = {0, };
 
-       content_retvm_if(album_id <= 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid album_id [%d]", album_id);
-       content_retvm_if(album == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid album");
+       content_retipm_if_fail(album_id > 0, "album_id [%d]", album_id);
+       content_retip_if_fail(album);
 
        snprintf(select_query, sizeof(select_query), SELECT_ALBUM_FROM_ALBUM, album_id);
 
@@ -89,12 +89,7 @@ int media_album_get_album_from_db(int album_id, media_album_h *album)
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        if (sqlite3_step(stmt) == SQLITE_ROW) {
-               media_album_s *_album = (media_album_s*)calloc(1, sizeof(media_album_s));
-               if (_album == NULL) {
-                       content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                       SQLITE3_FINALIZE(stmt);
-                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-               }
+               media_album_s *_album = g_new0(media_album_s, 1);
 
                _album->album_id = album_id;
                _album->name = g_strdup((const char *)sqlite3_column_text(stmt, 0));
@@ -115,10 +110,10 @@ int media_album_destroy(media_album_h album)
        media_album_s *_album = (media_album_s*)album;
 
        if (_album) {
-               SAFE_FREE(_album->name);
-               SAFE_FREE(_album->artist);
-               SAFE_FREE(_album->album_art_path);
-               SAFE_FREE(_album);
+               g_free(_album->name);
+               g_free(_album->artist);
+               g_free(_album->album_art_path);
+               g_free(_album);
 
                ret = MEDIA_CONTENT_ERROR_NONE;
        } else {
@@ -131,51 +126,21 @@ int media_album_destroy(media_album_h album)
 
 int media_album_clone(media_album_h *dst, media_album_h src)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_album_s *_src = (media_album_s*)src;
 
-       if (_src != NULL) {
-               media_album_s *_dst = (media_album_s*)calloc(1, sizeof(media_album_s));
-               content_retvm_if(_dst == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-
-               _dst->album_id = _src->album_id;
-
-               if (_src->name != NULL) {
-                       _dst->name = g_strdup(_src->name);
-                       if (_dst->name == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               media_album_destroy((media_album_h)_dst);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               }
-
-               if (_src->artist != NULL) {
-                       _dst->artist = g_strdup(_src->artist);
-                       if (_dst->artist == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               media_album_destroy((media_album_h)_dst);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               }
-
-               if (_src->album_art_path != NULL) {
-                       _dst->album_art_path = g_strdup(_src->album_art_path);
-                       if (_dst->album_art_path == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               media_album_destroy((media_album_h)_dst);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               }
-
-               *dst = (media_album_h)_dst;
+       content_retip_if_fail(dst);
+       content_retip_if_fail(src);
 
-               ret = MEDIA_CONTENT_ERROR_NONE;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       media_album_s *_dst = g_new0(media_album_s, 1);
 
-       return ret;
+       _dst->album_id = _src->album_id;
+       _dst->name = g_strdup(_src->name);
+       _dst->artist = g_strdup(_src->artist);
+       _dst->album_art_path = g_strdup(_src->album_art_path);
+
+       *dst = (media_album_h)_dst;
+
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_album_get_album_id(media_album_h album, int *album_id)
@@ -196,68 +161,38 @@ int media_album_get_album_id(media_album_h album, int *album_id)
 
 int media_album_get_name(media_album_h album, char **name)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_album_s *_album = (media_album_s*)album;
 
-       if (_album) {
-               if (_album->name != NULL) {
-                       *name = g_strdup(_album->name);
-                       content_retvm_if(*name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-               } else {
-                       *name = NULL;
-               }
+       content_retip_if_fail(album);
+       content_retip_if_fail(name);
 
-               ret = MEDIA_CONTENT_ERROR_NONE;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       *name = g_strdup(_album->name);
 
-       return ret;
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_album_get_artist(media_album_h album, char **artist)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_album_s *_album = (media_album_s*)album;
 
-       if (_album) {
-               if (_album->artist != NULL) {
-                       *artist = g_strdup(_album->artist);
-                       content_retvm_if(*artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-               } else {
-                       *artist = NULL;
-               }
+       content_retip_if_fail(album);
+       content_retip_if_fail(artist);
 
-               ret = MEDIA_CONTENT_ERROR_NONE;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       *artist = g_strdup(_album->artist);
 
-       return ret;
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_album_get_album_art(media_album_h album, char **album_art)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_album_s *_album = (media_album_s*)album;
 
-       if (_album) {
-               if (_album->album_art_path != NULL) {
-                       *album_art = g_strdup(_album->album_art_path);
-                       content_retvm_if(*album_art == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-               } else {
-                       *album_art = NULL;
-               }
+       content_retip_if_fail(album);
+       content_retip_if_fail(album_art);
 
-               ret = MEDIA_CONTENT_ERROR_NONE;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       *album_art = g_strdup(_album->album_art_path);
 
-       return ret;
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_group_get_group_count_from_db(filter_h filter, media_group_e group, int *group_count)
index aa77ac3..11eb91a 100755 (executable)
@@ -22,11 +22,11 @@ int image_meta_destroy(image_meta_h image)
        image_meta_s *_image = (image_meta_s*)image;
        content_retvm_if(_image == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Image handle is null");
 
-       SAFE_FREE(_image->media_id);
-       SAFE_FREE(_image->date_taken);
-       SAFE_FREE(_image->exposure_time);
-       SAFE_FREE(_image->model);
-       SAFE_FREE(_image);
+       g_free(_image->media_id);
+       g_free(_image->date_taken);
+       g_free(_image->exposure_time);
+       g_free(_image->model);
+       g_free(_image);
 
        return MEDIA_CONTENT_ERROR_NONE;
 }
@@ -34,10 +34,11 @@ int image_meta_destroy(image_meta_h image)
 int image_meta_clone(image_meta_h *dst, image_meta_h src)
 {
        image_meta_s *_src = (image_meta_s*)src;
-       content_retvm_if(!_src, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Source handle is null");
 
-       image_meta_s *_dst = (image_meta_s*)calloc(1, sizeof(image_meta_s));
-       content_retvm_if(!_dst, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+       content_retip_if_fail(dst);
+       content_retip_if_fail(src);
+
+       image_meta_s *_dst = g_new0(image_meta_s, 1);
 
        _dst->media_id = g_strdup(_src->media_id);
        _dst->date_taken = g_strdup(_src->date_taken);
@@ -57,7 +58,9 @@ int image_meta_clone(image_meta_h *dst, image_meta_h src)
 int image_meta_get_media_id(image_meta_h image, char **media_id)
 {
        image_meta_s *_image = (image_meta_s*)image;
-       content_retvm_if(!_image || !media_id, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+       content_retip_if_fail(image);
+       content_retip_if_fail(media_id);
 
        *media_id = g_strdup(_image->media_id);
 
@@ -96,7 +99,9 @@ int image_meta_get_orientation(image_meta_h image, media_content_orientation_e*
 int image_meta_get_date_taken(image_meta_h image, char **date_taken)
 {
        image_meta_s *_image = (image_meta_s*)image;
-       content_retvm_if(!_image || !date_taken, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+       content_retip_if_fail(image);
+       content_retip_if_fail(date_taken);
 
        *date_taken = g_strdup(_image->date_taken);
 
@@ -106,7 +111,9 @@ int image_meta_get_date_taken(image_meta_h image, char **date_taken)
 int image_meta_get_exposure_time(image_meta_h image, char **exposure_time)
 {
        image_meta_s *_image = (image_meta_s*)image;
-       content_retvm_if(!_image || !exposure_time, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+       content_retip_if_fail(image);
+       content_retip_if_fail(exposure_time);
 
        *exposure_time = g_strdup(_image->exposure_time);
 
@@ -136,7 +143,9 @@ int image_meta_get_iso(image_meta_h image, int *iso)
 int image_meta_get_model(image_meta_h image, char **model)
 {
        image_meta_s *_image = (image_meta_s*)image;
-       content_retvm_if(!_image || !model, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+       content_retip_if_fail(image);
+       content_retip_if_fail(model);
 
        *model = g_strdup(_image->model);
 
@@ -169,7 +178,7 @@ int image_meta_update_to_db(image_meta_h image)
                ret = _media_db_get_storage_id_by_media_id(_image->media_id, &storage_id);
                content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
                sql = sqlite3_mprintf(UPDATE_IMAGE_META_FROM_MEDIA, storage_id, _image->orientation, _image->media_id);
-               SAFE_FREE(storage_id);
+               g_free(storage_id);
 #else
                sql = sqlite3_mprintf(UPDATE_IMAGE_META_FROM_MEDIA, _image->orientation, _image->media_id);
 #endif
index 6bdfec0..3cb6688 100644 (file)
 #include <media_util_private.h>
 #include <system_info.h>
 
-
-#define media_content_retv_free_info_if(expr, val, p_str) do { \
-                               if (expr) {     \
-                                       LOGE(FONT_COLOR_RED"Memory allocation failure"FONT_COLOR_RESET);        \
-                                       media_info_destroy(p_str);      \
-                                       return (val);   \
-                               }       \
-                       } while (0)
-
-
 static void __media_info_insert_completed_cb(media_request_result_s *result, void *user_data);
 static void __media_info_thumbnail_completed_cb(int error, const char *path, void *user_data);
 static void __media_info_face_completed_cb(int error, const int face_count, void *user_data);
@@ -81,11 +71,11 @@ static void __media_info_insert_completed_cb(media_request_result_s *result, voi
                if (STRING_VALID(_cb_data->insert_list_path)) {
                        if (unlink(_cb_data->insert_list_path) < 0)
                                content_stderror("failed to delete");
-                       SAFE_FREE(_cb_data->insert_list_path);
+                       g_free(_cb_data->insert_list_path);
                }
        }
 
-       SAFE_FREE(_cb_data);
+       g_free(_cb_data);
 
        return;
 }
@@ -101,8 +91,7 @@ static void __media_info_thumbnail_completed_cb(int error, const char *path, voi
                media = _thumb_cb->handle;
 
                if (media != NULL) {
-                       if (media->thumbnail_path != NULL)
-                               SAFE_FREE(media->thumbnail_path);
+                       g_free(media->thumbnail_path);
 
                        if (STRING_VALID(path))
                                media->thumbnail_path = g_strdup(path);
@@ -116,7 +105,7 @@ static void __media_info_thumbnail_completed_cb(int error, const char *path, voi
                        _thumb_cb->thumbnail_completed_cb(error_value, path, _thumb_cb->user_data);
        }
 
-       SAFE_FREE(_thumb_cb);
+       g_free(_thumb_cb);
 
        return;
 }
@@ -148,7 +137,7 @@ static void __media_info_face_completed_cb(int error, const int face_count, void
                        _face_cb->face_completed_cb(error_value, face_count, _face_cb->user_data);
        }
 
-       SAFE_FREE(_face_cb);
+       g_free(_face_cb);
 
        return;
 }
@@ -231,8 +220,7 @@ static int __media_info_insert_batch(const char **path_array,
 
        fclose(fp);
 
-       media_insert_cb_s *_cb_data = (media_insert_cb_s *)calloc(1, sizeof(media_insert_cb_s));
-       content_retvm_if(_cb_data == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+       media_insert_cb_s *_cb_data = g_new0(media_insert_cb_s, 1);
 
        _cb_data->insert_completed_cb = completed_cb;
        _cb_data->user_data = user_data;
@@ -274,6 +262,9 @@ void _media_info_item_get_detail(sqlite3_stmt* stmt, media_info_h media)
 {
        media_info_s *_media = (media_info_s*)media;
 
+       if (!_media)
+               return;
+
        _media->media_id = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_UUID));
        _media->file_path = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_PATH));
        _media->display_name = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_FILE_NAME));
@@ -303,57 +294,56 @@ void _media_info_item_get_detail(sqlite3_stmt* stmt, media_info_h media)
 #endif
 
        if (_media->media_type == MEDIA_CONTENT_TYPE_IMAGE) {
-               _media->image_meta = (image_meta_s *)calloc(1, sizeof(image_meta_s));
-               if (_media->image_meta) {
-                       _media->image_meta->media_id = g_strdup(_media->media_id);
-                       _media->image_meta->width = sqlite3_column_int(stmt, MEDIA_INFO_WIDTH);
-                       _media->image_meta->height = sqlite3_column_int(stmt, MEDIA_INFO_HEIGHT);
-                       _media->image_meta->fnumber = (double)sqlite3_column_double(stmt, MEDIA_INFO_FNUMBER);
-                       _media->image_meta->iso = sqlite3_column_int(stmt, MEDIA_INFO_ISO);
-                       _media->image_meta->date_taken = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_DATETAKEN));
-                       _media->image_meta->orientation = sqlite3_column_int(stmt, MEDIA_INFO_ORIENTATION);
-                       _media->image_meta->exposure_time = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_EXPOSURE_TIME));
-                       _media->image_meta->model = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_MODEL));
-               }
+               _media->image_meta = g_new0(image_meta_s, 1);
+
+               _media->image_meta->media_id = g_strdup(_media->media_id);
+               _media->image_meta->width = sqlite3_column_int(stmt, MEDIA_INFO_WIDTH);
+               _media->image_meta->height = sqlite3_column_int(stmt, MEDIA_INFO_HEIGHT);
+               _media->image_meta->fnumber = (double)sqlite3_column_double(stmt, MEDIA_INFO_FNUMBER);
+               _media->image_meta->iso = sqlite3_column_int(stmt, MEDIA_INFO_ISO);
+               _media->image_meta->date_taken = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_DATETAKEN));
+               _media->image_meta->orientation = sqlite3_column_int(stmt, MEDIA_INFO_ORIENTATION);
+               _media->image_meta->exposure_time = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_EXPOSURE_TIME));
+               _media->image_meta->model = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_MODEL));
+
        } else if (_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
-               _media->video_meta = (video_meta_s *)calloc(1, sizeof(video_meta_s));
-               if (_media->video_meta) {
-                       _media->video_meta->media_id = g_strdup(_media->media_id);
-                       _media->video_meta->width = sqlite3_column_int(stmt, MEDIA_INFO_WIDTH);
-                       _media->video_meta->height = sqlite3_column_int(stmt, MEDIA_INFO_HEIGHT);
-                       _media->video_meta->album = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM));
-                       _media->video_meta->artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ARTIST));
-                       _media->video_meta->album_artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM_ARTIST));
-                       _media->video_meta->genre = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_GENRE));
-                       _media->video_meta->composer = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COMPOSER));
-                       _media->video_meta->year = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_YEAR));
-                       _media->video_meta->recorded_date = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_RECORDED_DATE));
-                       _media->video_meta->copyright = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COPYRIGHT));
-                       _media->video_meta->track_num = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TRACK_NUM));
-                       _media->video_meta->bitrate = sqlite3_column_int(stmt, MEDIA_INFO_BITRATE);
-                       _media->video_meta->duration = sqlite3_column_int(stmt, MEDIA_INFO_DURATION);
-                       _media->video_meta->rotation = sqlite3_column_int(stmt, MEDIA_INFO_ORIENTATION);
-               }
+               _media->video_meta = g_new0(video_meta_s, 1);
+
+               _media->video_meta->media_id = g_strdup(_media->media_id);
+               _media->video_meta->width = sqlite3_column_int(stmt, MEDIA_INFO_WIDTH);
+               _media->video_meta->height = sqlite3_column_int(stmt, MEDIA_INFO_HEIGHT);
+               _media->video_meta->album = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM));
+               _media->video_meta->artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ARTIST));
+               _media->video_meta->album_artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM_ARTIST));
+               _media->video_meta->genre = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_GENRE));
+               _media->video_meta->composer = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COMPOSER));
+               _media->video_meta->year = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_YEAR));
+               _media->video_meta->recorded_date = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_RECORDED_DATE));
+               _media->video_meta->copyright = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COPYRIGHT));
+               _media->video_meta->track_num = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TRACK_NUM));
+               _media->video_meta->bitrate = sqlite3_column_int(stmt, MEDIA_INFO_BITRATE);
+               _media->video_meta->duration = sqlite3_column_int(stmt, MEDIA_INFO_DURATION);
+               _media->video_meta->rotation = sqlite3_column_int(stmt, MEDIA_INFO_ORIENTATION);
 
        } else if ((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
-               _media->audio_meta = (audio_meta_s *)calloc(1, sizeof(audio_meta_s));
-               if (_media->audio_meta) {
-                       _media->audio_meta->media_id = g_strdup(_media->media_id);
-                       _media->audio_meta->album = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM));
-                       _media->audio_meta->artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ARTIST));
-                       _media->audio_meta->album_artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM_ARTIST));
-                       _media->audio_meta->genre = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_GENRE));
-                       _media->audio_meta->composer = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COMPOSER));
-                       _media->audio_meta->year = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_YEAR));
-                       _media->audio_meta->recorded_date = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_RECORDED_DATE));
-                       _media->audio_meta->copyright = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COPYRIGHT));
-                       _media->audio_meta->track_num = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TRACK_NUM));
-                       _media->audio_meta->bitrate = sqlite3_column_int(stmt, MEDIA_INFO_BITRATE);
-                       _media->audio_meta->bitpersample = sqlite3_column_int(stmt, MEDIA_INFO_BITPERSAMPLE);
-                       _media->audio_meta->duration = sqlite3_column_int(stmt, MEDIA_INFO_DURATION);
-                       _media->audio_meta->samplerate = sqlite3_column_int(stmt, MEDIA_INFO_SAMPLERATE);
-                       _media->audio_meta->channel = sqlite3_column_int(stmt, MEDIA_INFO_CHANNEL);
-               }
+               _media->audio_meta = g_new0(audio_meta_s, 1);
+
+               _media->audio_meta->media_id = g_strdup(_media->media_id);
+               _media->audio_meta->album = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM));
+               _media->audio_meta->artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ARTIST));
+               _media->audio_meta->album_artist = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_ALBUM_ARTIST));
+               _media->audio_meta->genre = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_GENRE));
+               _media->audio_meta->composer = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COMPOSER));
+               _media->audio_meta->year = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_YEAR));
+               _media->audio_meta->recorded_date = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_RECORDED_DATE));
+               _media->audio_meta->copyright = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COPYRIGHT));
+               _media->audio_meta->track_num = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_TRACK_NUM));
+               _media->audio_meta->bitrate = sqlite3_column_int(stmt, MEDIA_INFO_BITRATE);
+               _media->audio_meta->bitpersample = sqlite3_column_int(stmt, MEDIA_INFO_BITPERSAMPLE);
+               _media->audio_meta->duration = sqlite3_column_int(stmt, MEDIA_INFO_DURATION);
+               _media->audio_meta->samplerate = sqlite3_column_int(stmt, MEDIA_INFO_SAMPLERATE);
+               _media->audio_meta->channel = sqlite3_column_int(stmt, MEDIA_INFO_CHANNEL);
+
        }
 }
 #ifdef _USE_TVPD_MODE
@@ -420,8 +410,8 @@ int media_info_insert_to_db(const char *path, media_info_h *info)
        ms_user_storage_type_e storage_type = MS_USER_STORAGE_INTERNAL;
        int modified_time = 0;
 
-       content_retvm_if(!STRING_VALID(path), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid path");
-       content_retvm_if(info == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid info");
+       content_retip_if_fail(STRING_VALID(path));
+       content_retip_if_fail(info);
 
        ret = _media_content_replace_path(path, repl_path);
        content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");
@@ -472,8 +462,8 @@ int media_info_insert_to_db(const char *path, media_info_h *info)
                return _content_error_capi(ret);
        }
 
-       media_info_s *_media = (media_info_s*)calloc(1, sizeof(media_info_s));
-       content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+       media_info_s *_media = g_new0(media_info_s, 1);
+
 #ifdef _USE_TVPD_MODE
        if (STRING_VALID(storage_id))
                ret = _media_info_get_media_info_from_db(repl_path, storage_id, (media_info_h)_media);
@@ -496,17 +486,17 @@ int media_info_insert_batch_to_db(const char **path_array, unsigned int array_le
        int ret = MS_MEDIA_ERR_NONE;
        char repl_path[MAX_PATH_LEN] = {0, };
 
-       content_retvm_if(path_array == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid path_array");
-       content_retvm_if(array_length <= 0, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid array_length");
+       content_retip_if_fail(path_array);
+       content_retip_if_fail(array_length > 0);
+       content_retip_if_fail(completed_cb);
 
-       repl_path_array = calloc(1, sizeof(char *) * array_length);
-       content_retvm_if(repl_path_array == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+       repl_path_array = g_malloc0(sizeof(char *) * array_length);
 
        for (idx = 0; idx < array_length; idx++) {
                if (STRING_VALID(path_array[idx])) {
                        memset(repl_path, 0, sizeof(repl_path));
                        _media_content_replace_path(path_array[idx], repl_path);
-                       repl_path_array[idx] = strndup(repl_path, strlen(repl_path));
+                       repl_path_array[idx] = g_strndup(repl_path, strlen(repl_path));
                } else {
                        content_error("path[%d] is invalid string", idx);
                }
@@ -514,9 +504,9 @@ int media_info_insert_batch_to_db(const char **path_array, unsigned int array_le
 
        ret = __media_info_insert_batch((const char **)repl_path_array, array_length, completed_cb, user_data);
        for (idx = 0; idx < array_length; idx++)
-               SAFE_FREE(repl_path_array[idx]);
+               g_free(repl_path_array[idx]);
 
-       SAFE_FREE(repl_path_array);
+       g_free(repl_path_array);
 
        return ret;
 }
@@ -535,8 +525,7 @@ int media_info_get_media_info_by_path_from_db(const char* path, media_info_h* me
                return _content_error_capi(ret);
        }
 
-       media_info_s *_media = (media_info_s*)calloc(1, sizeof(media_info_s));
-       content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+       media_info_s *_media = g_new0(media_info_s, 1);
 
        ret =  _media_info_get_media_info_from_db(path, storage_id, (media_info_h)_media);
        *media = (media_info_h)_media;
@@ -560,20 +549,20 @@ int media_info_delete_from_db(const char *media_id)
        ret = __media_info_get_media_path_by_id_from_db(media_id, &path);
        if (ret != MEDIA_CONTENT_ERROR_NONE) {
                content_error("__media_info_get_media_path_by_id_from_db failed : %d", ret);
-               SAFE_FREE(path);
+               g_free(path);
                return ret;
        }
 
        ret = _media_db_get_storage_id_by_media_id(media_id, &storage_id);
        if (ret != MEDIA_CONTENT_ERROR_NONE) {
                content_error("_media_db_get_storage_id_by_media_id failed : %d", ret);
-               SAFE_FREE(path);
+               g_free(path);
                return ret;
        }
 
        ret = media_svc_delete_item_by_path(_content_get_db_handle(), storage_id, path, _content_get_uid());
-       SAFE_FREE(path);
-       SAFE_FREE(storage_id);
+       g_free(path);
+       g_free(storage_id);
 
        return _content_error_capi(ret);
 }
@@ -583,62 +572,62 @@ int media_info_destroy(media_info_h media)
        media_info_s *_media = (media_info_s*)media;
        content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Handle is null");
 
-       SAFE_FREE(_media->media_id);
-       SAFE_FREE(_media->file_path);
-       SAFE_FREE(_media->display_name);
-       SAFE_FREE(_media->mime_type);
-       SAFE_FREE(_media->thumbnail_path);
-       SAFE_FREE(_media->description);
-       SAFE_FREE(_media->title);
+       g_free(_media->media_id);
+       g_free(_media->file_path);
+       g_free(_media->display_name);
+       g_free(_media->mime_type);
+       g_free(_media->thumbnail_path);
+       g_free(_media->description);
+       g_free(_media->title);
 #ifdef _USE_TVPD_MODE
-       SAFE_FREE(_media->modified_month);
+       g_free(_media->modified_month);
 #endif
-       SAFE_FREE(_media->storage_uuid);
+       g_free(_media->storage_uuid);
 #ifdef _USE_SENIOR_MODE
-       SAFE_FREE(_media->contact);
-       SAFE_FREE(_media->app_data);
+       g_free(_media->contact);
+       g_free(_media->app_data);
 #endif
 
        if (_media->image_meta) {
-               SAFE_FREE(_media->image_meta->media_id);
-               SAFE_FREE(_media->image_meta->date_taken);
-               SAFE_FREE(_media->image_meta->exposure_time);
-               SAFE_FREE(_media->image_meta->model);
+               g_free(_media->image_meta->media_id);
+               g_free(_media->image_meta->date_taken);
+               g_free(_media->image_meta->exposure_time);
+               g_free(_media->image_meta->model);
 
-               SAFE_FREE(_media->image_meta);
+               g_free(_media->image_meta);
        }
 
        if (_media->video_meta) {
-               SAFE_FREE(_media->video_meta->media_id);
-               SAFE_FREE(_media->video_meta->album);
-               SAFE_FREE(_media->video_meta->artist);
-               SAFE_FREE(_media->video_meta->album_artist);
-               SAFE_FREE(_media->video_meta->genre);
-               SAFE_FREE(_media->video_meta->composer);
-               SAFE_FREE(_media->video_meta->year);
-               SAFE_FREE(_media->video_meta->recorded_date);
-               SAFE_FREE(_media->video_meta->copyright);
-               SAFE_FREE(_media->video_meta->track_num);
+               g_free(_media->video_meta->media_id);
+               g_free(_media->video_meta->album);
+               g_free(_media->video_meta->artist);
+               g_free(_media->video_meta->album_artist);
+               g_free(_media->video_meta->genre);
+               g_free(_media->video_meta->composer);
+               g_free(_media->video_meta->year);
+               g_free(_media->video_meta->recorded_date);
+               g_free(_media->video_meta->copyright);
+               g_free(_media->video_meta->track_num);
 
-               SAFE_FREE(_media->video_meta);
+               g_free(_media->video_meta);
        }
 
        if (_media->audio_meta) {
-               SAFE_FREE(_media->audio_meta->media_id);
-               SAFE_FREE(_media->audio_meta->album);
-               SAFE_FREE(_media->audio_meta->artist);
-               SAFE_FREE(_media->audio_meta->album_artist);
-               SAFE_FREE(_media->audio_meta->genre);
-               SAFE_FREE(_media->audio_meta->composer);
-               SAFE_FREE(_media->audio_meta->year);
-               SAFE_FREE(_media->audio_meta->recorded_date);
-               SAFE_FREE(_media->audio_meta->copyright);
-               SAFE_FREE(_media->audio_meta->track_num);
+               g_free(_media->audio_meta->media_id);
+               g_free(_media->audio_meta->album);
+               g_free(_media->audio_meta->artist);
+               g_free(_media->audio_meta->album_artist);
+               g_free(_media->audio_meta->genre);
+               g_free(_media->audio_meta->composer);
+               g_free(_media->audio_meta->year);
+               g_free(_media->audio_meta->recorded_date);
+               g_free(_media->audio_meta->copyright);
+               g_free(_media->audio_meta->track_num);
 
-               SAFE_FREE(_media->audio_meta);
+               g_free(_media->audio_meta);
        }
 
-       SAFE_FREE(_media);
+       g_free(_media);
 
        return MEDIA_CONTENT_ERROR_NONE;
 }
@@ -646,61 +635,26 @@ int media_info_destroy(media_info_h media)
 int media_info_clone(media_info_h *dst, media_info_h src)
 {
        media_info_s *_src = (media_info_s*)src;
-       content_retvm_if(_src == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Source handle is null");
 
-       media_info_s *_dst = (media_info_s*)calloc(1, sizeof(media_info_s));
-       content_retvm_if(_dst == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+       content_retip_if_fail(dst);
+       content_retip_if_fail(src);
 
-       if (_src->media_id) {
-               _dst->media_id = g_strdup(_src->media_id);
-               media_content_retv_free_info_if(_dst->media_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-       }
-       if (_src->file_path) {
-               _dst->file_path = g_strdup(_src->file_path);
-               media_content_retv_free_info_if(_dst->file_path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-       }
-       if (_src->display_name != NULL) {
-               _dst->display_name = g_strdup(_src->display_name);
-               media_content_retv_free_info_if(_dst->display_name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-       }
-       if (_src->mime_type) {
-               _dst->mime_type = g_strdup(_src->mime_type);
-               media_content_retv_free_info_if(_dst->mime_type == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-       }
-       if (_src->thumbnail_path != NULL) {
-               _dst->thumbnail_path = g_strdup(_src->thumbnail_path);
-               media_content_retv_free_info_if(_dst->thumbnail_path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-       }
-       if (_src->description != NULL) {
-               _dst->description = g_strdup(_src->description);
-               media_content_retv_free_info_if(_dst->description == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-       }
-
-       if (_src->title != NULL) {
-               _dst->title = g_strdup(_src->title);
-               media_content_retv_free_info_if(_dst->title == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-       }
+       media_info_s *_dst = g_new0(media_info_s, 1);
 
-       if (_src->storage_uuid != NULL) {
-               _dst->storage_uuid = g_strdup(_src->storage_uuid);
-               media_content_retv_free_info_if(_dst->storage_uuid == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-       }
+       _dst->media_id = g_strdup(_src->media_id);
+       _dst->file_path = g_strdup(_src->file_path);
+       _dst->display_name = g_strdup(_src->display_name);
+       _dst->mime_type = g_strdup(_src->mime_type);
+       _dst->thumbnail_path = g_strdup(_src->thumbnail_path);
+       _dst->description = g_strdup(_src->description);
+       _dst->title = g_strdup(_src->title);
+       _dst->storage_uuid = g_strdup(_src->storage_uuid);
 #ifdef _USE_TVPD_MODE
-       if (STRING_VALID(_src->modified_month)) {
-               _dst->modified_month = strdup(_src->modified_month);
-               media_content_retv_free_info_if(_dst->modified_month == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-       }
+               _dst->modified_month = g_strdup(_src->modified_month);
 #endif
 #ifdef _USE_SENIOR_MODE
-       if (STRING_VALID(_src->contact)) {
-               _dst->contact = strdup(_src->contact);
-               media_content_retv_free_info_if(_dst->contact == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-       }
-
-       if (STRING_VALID(_src->app_data)) {
-               _dst->app_data = strdup(_src->app_data);
-               media_content_retv_free_info_if(_dst->app_data == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-       }
+       _dst->contact = g_strdup(_src->contact);
+       _dst->app_data = g_strdup(_src->app_data);
 #endif
 
        _dst->media_type = _src->media_type;
@@ -727,29 +681,12 @@ int media_info_clone(media_info_h *dst, media_info_h src)
 #endif
 
        if (_src->media_type == MEDIA_CONTENT_TYPE_IMAGE && _src->image_meta) {
-               _dst->image_meta = (image_meta_s *)calloc(1, sizeof(image_meta_s));
-               media_content_retv_free_info_if(_dst->image_meta == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-
-               if (_src->image_meta->media_id != NULL) {
-                       _dst->image_meta->media_id = g_strdup(_src->image_meta->media_id);
-                       media_content_retv_free_info_if(_dst->image_meta->media_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-               }
-
-               if (_src->image_meta->date_taken != NULL) {
-                       _dst->image_meta->date_taken = g_strdup(_src->image_meta->date_taken);
-                       media_content_retv_free_info_if(_dst->image_meta->date_taken == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-               }
-
-               if (_src->image_meta->exposure_time != NULL) {
-                       _dst->image_meta->exposure_time = g_strdup(_src->image_meta->exposure_time);
-                       media_content_retv_free_info_if(_dst->image_meta->exposure_time == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-               }
-
-               if (_src->image_meta->model != NULL) {
-                       _dst->image_meta->model = g_strdup(_src->image_meta->model);
-                       media_content_retv_free_info_if(_dst->image_meta->model == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-               }
+               _dst->image_meta = g_new0(image_meta_s, 1);
 
+               _dst->image_meta->media_id = g_strdup(_src->image_meta->media_id);
+               _dst->image_meta->date_taken = g_strdup(_src->image_meta->date_taken);
+               _dst->image_meta->exposure_time = g_strdup(_src->image_meta->exposure_time);
+               _dst->image_meta->model = g_strdup(_src->image_meta->model);
                _dst->image_meta->fnumber = _src->image_meta->fnumber;
                _dst->image_meta->iso = _src->image_meta->iso;
                _dst->image_meta->width = _src->image_meta->width;
@@ -757,50 +694,18 @@ int media_info_clone(media_info_h *dst, media_info_h src)
                _dst->image_meta->orientation = _src->image_meta->orientation;
 
        } else if (_src->media_type == MEDIA_CONTENT_TYPE_VIDEO && _src->video_meta) {
-               _dst->video_meta = (video_meta_s *)calloc(1, sizeof(video_meta_s));
-               media_content_retv_free_info_if(_dst->video_meta == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-
-               if (_src->video_meta->media_id != NULL) {
-                       _dst->video_meta->media_id = g_strdup(_src->video_meta->media_id);
-                       media_content_retv_free_info_if(_dst->video_meta->media_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-               }
-               if (_src->video_meta->album != NULL) {
-                       _dst->video_meta->album = g_strdup(_src->video_meta->album);
-                       media_content_retv_free_info_if(_dst->video_meta->album == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-               }
-               if (_src->video_meta->artist != NULL) {
-                       _dst->video_meta->artist = g_strdup(_src->video_meta->artist);
-                       media_content_retv_free_info_if(_dst->video_meta->artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-               }
-               if (_src->video_meta->album_artist != NULL) {
-                       _dst->video_meta->album_artist = g_strdup(_src->video_meta->album_artist);
-                       media_content_retv_free_info_if(_dst->video_meta->album_artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-               }
-               if (_src->video_meta->genre != NULL) {
-                       _dst->video_meta->genre = g_strdup(_src->video_meta->genre);
-                       media_content_retv_free_info_if(_dst->video_meta->genre == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-               }
-               if (_src->video_meta->composer != NULL) {
-                       _dst->video_meta->composer = g_strdup(_src->video_meta->composer);
-                       media_content_retv_free_info_if(_dst->video_meta->composer == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-               }
-               if (_src->video_meta->year != NULL) {
-                       _dst->video_meta->year = g_strdup(_src->video_meta->year);
-                       media_content_retv_free_info_if(_dst->video_meta->year == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-               }
-               if (_src->video_meta->recorded_date != NULL) {
-                       _dst->video_meta->recorded_date = g_strdup(_src->video_meta->recorded_date);
-                       media_content_retv_free_info_if(_dst->video_meta->recorded_date == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-               }
-               if (_src->video_meta->copyright != NULL) {
-                       _dst->video_meta->copyright = g_strdup(_src->video_meta->copyright);
-                       media_content_retv_free_info_if(_dst->video_meta->copyright == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-               }
-               if (_src->video_meta->track_num != NULL) {
-                       _dst->video_meta->track_num = g_strdup(_src->video_meta->track_num);
-                       media_content_retv_free_info_if(_dst->video_meta->track_num == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-               }
-
+               _dst->video_meta = g_new0(video_meta_s, 1);
+
+               _dst->video_meta->media_id = g_strdup(_src->video_meta->media_id);
+               _dst->video_meta->album = g_strdup(_src->video_meta->album);
+               _dst->video_meta->artist = g_strdup(_src->video_meta->artist);
+               _dst->video_meta->album_artist = g_strdup(_src->video_meta->album_artist);
+               _dst->video_meta->genre = g_strdup(_src->video_meta->genre);
+               _dst->video_meta->composer = g_strdup(_src->video_meta->composer);
+               _dst->video_meta->year = g_strdup(_src->video_meta->year);
+               _dst->video_meta->recorded_date = g_strdup(_src->video_meta->recorded_date);
+               _dst->video_meta->copyright = g_strdup(_src->video_meta->copyright);
+               _dst->video_meta->track_num = g_strdup(_src->video_meta->track_num);
                _dst->video_meta->width = _src->video_meta->width;
                _dst->video_meta->height = _src->video_meta->height;
                _dst->video_meta->duration = _src->video_meta->duration;
@@ -808,56 +713,25 @@ int media_info_clone(media_info_h *dst, media_info_h src)
                _dst->video_meta->rotation = _src->video_meta->rotation;
 
        } else if ((_src->media_type == MEDIA_CONTENT_TYPE_MUSIC || _src->media_type == MEDIA_CONTENT_TYPE_SOUND) && _src->audio_meta) {
-               _dst->audio_meta = (audio_meta_s *)calloc(1, sizeof(audio_meta_s));
-               media_content_retv_free_info_if(_dst->audio_meta == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-
-               if (_src->audio_meta->media_id != NULL) {
-                       _dst->audio_meta->media_id = g_strdup(_src->audio_meta->media_id);
-                       media_content_retv_free_info_if(_dst->audio_meta->media_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-               }
-               if (_src->audio_meta->album != NULL) {
-                       _dst->audio_meta->album = g_strdup(_src->audio_meta->album);
-                       media_content_retv_free_info_if(_dst->audio_meta->album == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-               }
-               if (_src->audio_meta->artist != NULL) {
-                       _dst->audio_meta->artist = g_strdup(_src->audio_meta->artist);
-                       media_content_retv_free_info_if(_dst->audio_meta->artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-               }
-               if (_src->audio_meta->album_artist != NULL) {
-                       _dst->audio_meta->album_artist = g_strdup(_src->audio_meta->album_artist);
-                       media_content_retv_free_info_if(_dst->audio_meta->album_artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-               }
-               if (_src->audio_meta->genre != NULL) {
-                       _dst->audio_meta->genre = g_strdup(_src->audio_meta->genre);
-                       media_content_retv_free_info_if(_dst->audio_meta->genre == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-               }
-               if (_src->audio_meta->composer != NULL) {
-                       _dst->audio_meta->composer = g_strdup(_src->audio_meta->composer);
-                       media_content_retv_free_info_if(_dst->audio_meta->composer == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-               }
-               if (_src->audio_meta->year != NULL) {
-                       _dst->audio_meta->year = g_strdup(_src->audio_meta->year);
-                       media_content_retv_free_info_if(_dst->audio_meta->year == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-               }
-               if (_src->audio_meta->recorded_date != NULL) {
-                       _dst->audio_meta->recorded_date = g_strdup(_src->audio_meta->recorded_date);
-                       media_content_retv_free_info_if(_dst->audio_meta->recorded_date == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-               }
-               if (_src->audio_meta->copyright != NULL) {
-                       _dst->audio_meta->copyright = g_strdup(_src->audio_meta->copyright);
-                       media_content_retv_free_info_if(_dst->audio_meta->copyright == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-               }
-               if (_src->audio_meta->track_num != NULL) {
-                       _dst->audio_meta->track_num = g_strdup(_src->audio_meta->track_num);
-                       media_content_retv_free_info_if(_dst->audio_meta->track_num == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (media_info_h)_dst);
-               }
-
+               _dst->audio_meta = g_new0(audio_meta_s, 1);
+
+               _dst->audio_meta->media_id = g_strdup(_src->audio_meta->media_id);
+               _dst->audio_meta->album = g_strdup(_src->audio_meta->album);
+               _dst->audio_meta->artist = g_strdup(_src->audio_meta->artist);
+               _dst->audio_meta->album_artist = g_strdup(_src->audio_meta->album_artist);
+               _dst->audio_meta->genre = g_strdup(_src->audio_meta->genre);
+               _dst->audio_meta->composer = g_strdup(_src->audio_meta->composer);
+               _dst->audio_meta->year = g_strdup(_src->audio_meta->year);
+               _dst->audio_meta->recorded_date = g_strdup(_src->audio_meta->recorded_date);
+               _dst->audio_meta->copyright = g_strdup(_src->audio_meta->copyright);
+               _dst->audio_meta->track_num = g_strdup(_src->audio_meta->track_num);
                _dst->audio_meta->channel = _src->audio_meta->channel;
                _dst->audio_meta->samplerate = _src->audio_meta->samplerate;
                _dst->audio_meta->duration = _src->audio_meta->duration;
                _dst->audio_meta->bitrate = _src->audio_meta->bitrate;
                _dst->audio_meta->bitpersample = _src->audio_meta->bitpersample;
        }
+
        *dst = (media_info_h)_dst;
 
        return MEDIA_CONTENT_ERROR_NONE;
@@ -980,12 +854,12 @@ int media_info_get_image(media_info_h media, image_meta_h *image)
 
        media_info_s *_media = (media_info_s*)media;
 
-       content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
-       content_retvm_if(_media->media_type != MEDIA_CONTENT_TYPE_IMAGE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media_type");
-       content_retvm_if(_media->image_meta == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid image_meta");
+       content_retip_if_fail(media);
+       content_retip_if_fail(_media->media_type == MEDIA_CONTENT_TYPE_IMAGE);
+       content_retip_if_fail(_media->image_meta);
+       content_retip_if_fail(image);
 
-       image_meta_s *_image = (image_meta_s*)calloc(1, sizeof(image_meta_s));
-       content_retvm_if(_image == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+       image_meta_s *_image = g_new0(image_meta_s, 1);
 
        _image->media_id = g_strdup(_media->media_id);
        _image->width = _media->image_meta->width;
@@ -1008,12 +882,12 @@ int media_info_get_video(media_info_h media, video_meta_h *video)
 
        media_info_s *_media = (media_info_s*)media;
 
-       content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
-       content_retvm_if(_media->media_type != MEDIA_CONTENT_TYPE_VIDEO, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media_type");
-       content_retvm_if(_media->video_meta == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid video_meta");
+       content_retip_if_fail(media);
+       content_retip_if_fail(_media->media_type == MEDIA_CONTENT_TYPE_VIDEO);
+       content_retip_if_fail(_media->video_meta);
+       content_retip_if_fail(video);
 
-       video_meta_s *_video = (video_meta_s*)calloc(1, sizeof(video_meta_s));
-       content_retvm_if(_video == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+       video_meta_s *_video = g_new0(video_meta_s, 1);
 
        _video->media_id = g_strdup(_media->media_id);
        _video->album = g_strdup(_media->video_meta->album);
@@ -1043,12 +917,12 @@ int media_info_get_audio(media_info_h media, audio_meta_h *audio)
 
        media_info_s *_media = (media_info_s*)media;
 
-       content_retvm_if(_media == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media");
-       content_retvm_if(_media->media_type != MEDIA_CONTENT_TYPE_MUSIC && _media->media_type != MEDIA_CONTENT_TYPE_SOUND, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid media_type");
-       content_retvm_if(_media->audio_meta == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid audio_meta");
+       content_retip_if_fail(media);
+       content_retip_if_fail(_media->media_type == MEDIA_CONTENT_TYPE_MUSIC);
+       content_retip_if_fail(_media->audio_meta);
+       content_retip_if_fail(audio);
 
-       audio_meta_s *_audio = (audio_meta_s*)calloc(1, sizeof(audio_meta_s));
-       content_retvm_if(_audio == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+       audio_meta_s *_audio = g_new0(audio_meta_s, 1);
 
        _audio->media_id = g_strdup(_media->media_id);
        _audio->album = g_strdup(_media->audio_meta->album);
@@ -1074,66 +948,38 @@ int media_info_get_audio(media_info_h media, audio_meta_h *audio)
 
 int media_info_get_media_id(media_info_h media, char **media_id)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_info_s *_media = (media_info_s*)media;
 
-       if (_media && media_id) {
-               if (STRING_VALID(_media->media_id)) {
-                       *media_id = strdup(_media->media_id);
-                       content_retvm_if(*media_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-               } else {
-                       *media_id = NULL;
-               }
-               ret = MEDIA_CONTENT_ERROR_NONE;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       content_retip_if_fail(media);
+       content_retip_if_fail(media_id);
 
-       return ret;
+       *media_id = g_strdup(_media->media_id);
+
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_info_get_file_path(media_info_h media, char **path)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_info_s *_media = (media_info_s*)media;
 
-       if (_media && path) {
-               if (STRING_VALID(_media->file_path)) {
-                       *path = strdup(_media->file_path);
-                       content_retvm_if(*path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-               } else {
-                       *path = NULL;
-               }
-               ret = MEDIA_CONTENT_ERROR_NONE;
+       content_retip_if_fail(media);
+       content_retip_if_fail(path);
 
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       *path = g_strdup(_media->file_path);
 
-       return ret;
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_info_get_display_name(media_info_h media, char **name)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_info_s *_media = (media_info_s*)media;
-       if (_media && name) {
-               if (_media->display_name != NULL) {
-                       *name = g_strdup(_media->display_name);
-                       content_retvm_if(*name == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-               } else {
-                       *name = NULL;
-               }
-               ret = MEDIA_CONTENT_ERROR_NONE;
 
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       content_retip_if_fail(media);
+       content_retip_if_fail(name);
 
-       return ret;
+       *name = g_strdup(_media->display_name);
+
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_info_get_media_type(media_info_h media, media_content_type_e *type)
@@ -1153,23 +999,14 @@ int media_info_get_media_type(media_info_h media, media_content_type_e *type)
 
 int media_info_get_mime_type(media_info_h media, char **mime_type)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_info_s *_media = (media_info_s*)media;
 
-       if (_media && mime_type) {
-               if (STRING_VALID(_media->mime_type)) {
-                       *mime_type = strdup(_media->mime_type);
-                       content_retvm_if(*mime_type == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-               } else {
-                       *mime_type = NULL;
-               }
-               ret = MEDIA_CONTENT_ERROR_NONE;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       content_retip_if_fail(media);
+       content_retip_if_fail(mime_type);
 
-       return ret;
+       *mime_type = g_strdup(_media->mime_type);
+
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_info_get_size(media_info_h media, unsigned long long *size)
@@ -1235,65 +1072,38 @@ int media_info_get_timeline(media_info_h media, time_t* time)
 
 int media_info_get_thumbnail_path(media_info_h media, char **path)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_info_s *_media = (media_info_s*)media;
-       if (_media && path) {
-               if (_media->thumbnail_path != NULL) {
-                       *path = g_strdup(_media->thumbnail_path);
-                       content_retvm_if(*path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-               } else {
-                       *path = NULL;
-               }
-               ret = MEDIA_CONTENT_ERROR_NONE;
 
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       content_retip_if_fail(media);
+       content_retip_if_fail(path);
 
-       return ret;
+       *path = g_strdup(_media->thumbnail_path);
+
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_info_get_title(media_info_h media, char **title)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_info_s *_media = (media_info_s*)media;
 
-       if (_media && title)    { /*title can be empty string*/
-               if (_media->title != NULL) {
-                       *title = g_strdup(_media->title);
-                       content_retvm_if(*title == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-               } else {
-                       *title = NULL;
-               }
-               ret = MEDIA_CONTENT_ERROR_NONE;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       content_retip_if_fail(media);
+       content_retip_if_fail(title);
 
-       return ret;
+       *title = g_strdup(_media->title);
+
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_info_get_description(media_info_h media, char **description)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_info_s *_media = (media_info_s*)media;
 
-       if (_media && description) {
-               if (_media->description != NULL) {      /*description can be empty string*/
-                       *description = g_strdup(_media->description);
-                       content_retvm_if(*description == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-               } else {
-                       *description = NULL;
-               }
-               ret = MEDIA_CONTENT_ERROR_NONE;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       content_retip_if_fail(media);
+       content_retip_if_fail(description);
 
-       return ret;
+       *description = g_strdup(_media->description);
+
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_info_get_longitude(media_info_h media, double* longitude)
@@ -1377,24 +1187,15 @@ int media_info_get_favorite(media_info_h media, bool* favorite)
 
 int media_info_get_storage_id(media_info_h media, char **storage_id)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        content_warn("DEPRECATION WARNING: media_info_get_storage_id() is deprecated and will be removed from next release.");
        media_info_s *_media = (media_info_s*)media;
 
-       if (_media && storage_id) {
-               if (STRING_VALID(_media->storage_uuid)) {
-                       *storage_id = strdup(_media->storage_uuid);
-                       content_retvm_if(*storage_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-               } else {
-                       *storage_id = NULL;
-                       ret = MEDIA_CONTENT_ERROR_DB_FAILED;
-               }
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       content_retip_if_fail(media);
+       content_retip_if_fail(storage_id);
 
-       return ret;
+       *storage_id = g_strdup(_media->storage_uuid);
+
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_info_is_drm(media_info_h media, bool *is_drm)
@@ -1449,44 +1250,26 @@ int media_info_get_storage_type(media_info_h media, media_content_storage_e *sto
 #ifdef _USE_SENIOR_MODE
 int media_info_set_contact(media_info_h media, const char *contact)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_info_s *_media = (media_info_s*)media;
 
-       if (_media != NULL) {
-               SAFE_FREE(_media->contact);
-               if (STRING_VALID(contact)) {
-                       _media->contact = strdup(contact);
-                       content_retvm_if(_media->contact == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-               } else {
-                       _media->contact = NULL;
-               }
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       content_retip_if_fail(media);
 
-       return ret;
+       g_free(_media->contact);
+       _media->contact = g_strdup(contact);
+
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_info_set_app_data(media_info_h media, const char *app_data)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_info_s *_media = (media_info_s*)media;
 
-       if (_media != NULL) {
-               SAFE_FREE(_media->app_data);
-               if (STRING_VALID(app_data)) {
-                       _media->app_data = strdup(app_data);
-                       content_retvm_if(_media->app_data == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-               } else {
-                       _media->app_data = NULL;
-               }
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       content_retip_if_fail(media);
 
-       return ret;
+       g_free(_media->app_data);
+       _media->app_data = g_strdup(app_data);
+
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_info_insert_to_db_with_contact_data(const char *path, const char* contact, const char* app_data, media_info_h *info)
@@ -1552,76 +1335,53 @@ int media_info_delete_item(const char *media_id)
        ret = __media_info_get_media_path_by_id_from_db(media_id, &path);
        if (ret != MEDIA_CONTENT_ERROR_NONE) {
                content_error("__media_info_get_media_path_by_id_from_db failed : %d", ret);
-               SAFE_FREE(path);
+               g_free(path);
                return ret;
        }
 
        ret = _media_db_get_storage_id_by_media_id(media_id, &storage_id);
        if (ret != MEDIA_CONTENT_ERROR_NONE) {
                content_error("_media_db_get_storage_id_by_media_id failed : %d", ret);
-               SAFE_FREE(path);
+               g_free(path);
                return ret;
        }
 
        ret = media_svc_delete_item_by_path(_content_get_db_handle(), storage_id, path, tzplatform_getuid(TZ_USER_NAME));
-       SAFE_FREE(storage_id);
+       g_free(storage_id);
        if (ret != MEDIA_CONTENT_ERROR_NONE) {
                content_error("remove from DB failed : %d", ret);
-               SAFE_FREE(path);
+               g_free(path);
                return ret;
        }
 
        ret = media_svc_remove_file(path);
-       SAFE_FREE(path);
+       g_free(path);
+
        return _content_error_capi(ret);
 }
 
 int media_info_get_contact(media_info_h media, char **contact)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_info_s *_media = (media_info_s*)media;
 
-       if (_media && contact) {
-               if (STRING_VALID(_media->contact)) {
-                       *contact = strdup(_media->contact);
-                       if (*contact == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               } else {
-                       *contact = NULL;
-               }
-               ret = MEDIA_CONTENT_ERROR_NONE;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       content_retip_if_fail(media);
+       content_retip_if_fail(contact);
 
-       return ret;
+       *contact = g_strdup(_media->contact);
+
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_info_get_app_data(media_info_h media, char **app_data)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_info_s *_media = (media_info_s*)media;
 
-       if (_media && app_data) {
-               if (STRING_VALID(_media->app_data)) {
-                       *app_data = strdup(_media->app_data);
-                       if (*app_data == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               } else {
-                       *app_data = NULL;
-               }
-               ret = MEDIA_CONTENT_ERROR_NONE;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       content_retip_if_fail(media);
+       content_retip_if_fail(app_data);
 
-       return ret;
+       *app_data = g_strdup(_media->app_data);
+
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 #endif
 #ifdef _USE_TVPD_MODE
@@ -1772,26 +1532,14 @@ int media_info_get_stitched_engine(media_info_h media, int *stitched_info)
 
 int media_info_get_modified_month(media_info_h media, char **modified_month)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_info_s *_media = (media_info_s*)media;
 
-       if (_media && modified_month) {
-               if (STRING_VALID(_media->modified_month)) {
-                       *modified_month = strdup(_media->modified_month);
-                       if (*modified_month == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               } else {
-                       *modified_month = NULL;
-               }
-               ret = MEDIA_CONTENT_ERROR_NONE;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       content_retip_if_fail(media);
+       content_retip_if_fail(modified_month);
 
-       return ret;
+       *modified_month = g_strdup(_media->modified_month);
+
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 #endif
@@ -1802,10 +1550,8 @@ int media_info_get_media_from_db(const char *media_id, media_info_h *media)
        char select_query[DEFAULT_QUERY_SIZE] = {0, };
        sqlite3_stmt *stmt = NULL;
 
-       if (!STRING_VALID(media_id) || (media == NULL)) {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       content_retip_if_fail(STRING_VALID(media_id));
+       content_retip_if_fail(media);
 
 #ifdef _USE_TVPD_MODE
        char *storage_id = NULL;
@@ -1813,7 +1559,7 @@ int media_info_get_media_from_db(const char *media_id, media_info_h *media)
        ret = _media_db_get_storage_id_by_media_id(media_id, &storage_id);
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
        snprintf(select_query, sizeof(select_query), SELECT_MEDIA_FROM_MEDIA, storage_id, media_id);
-       SAFE_FREE(storage_id);
+       g_free(storage_id);
 #else
        snprintf(select_query, sizeof(select_query), SELECT_MEDIA_FROM_MEDIA, media_id);
 #endif
@@ -1823,13 +1569,7 @@ int media_info_get_media_from_db(const char *media_id, media_info_h *media)
        media_info_s *_media = NULL;
 
        if (sqlite3_step(stmt) == SQLITE_ROW) {
-               _media = (media_info_s*)calloc(1, sizeof(media_info_s));
-
-               if (_media == NULL) {
-                       content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                       SQLITE3_FINALIZE(stmt);
-                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-               }
+               _media = g_new0(media_info_s, 1);
 
                _media_info_item_get_detail(stmt, (media_info_h)_media);
 
@@ -1962,27 +1702,27 @@ int media_info_move_to_db(media_info_h media, const char* dst_path)
 
 int media_info_create_thumbnail(media_info_h media, media_thumbnail_completed_cb callback, void *user_data)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        content_warn("DEPRECATION WARNING: media_info_create_thumbnail() is deprecated and will be removed from next release. Use media_info_generate_thumbnail() instead.");
+       int ret = MEDIA_CONTENT_ERROR_NONE;
        static unsigned int req_id = 0;
        media_info_s *_media = (media_info_s*)media;
 
-       if (_media != NULL && STRING_VALID(_media->media_id) && STRING_VALID(_media->file_path)) {
-               media_thumbnail_cb_s *_thumb_cb = (media_thumbnail_cb_s*)calloc(1, sizeof(media_thumbnail_cb_s));
-               content_retvm_if(_thumb_cb == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-               req_id++;
-               _media->request_id = req_id;
+       content_retip_if_fail(media);
+       content_retip_if_fail(callback);
+       content_retip_if_fail(STRING_VALID(_media->media_id));
+       content_retip_if_fail(_media->file_path);
 
-               _thumb_cb->handle = _media;
-               _thumb_cb->user_data = user_data;
-               _thumb_cb->thumbnail_completed_cb = callback;
+       media_thumbnail_cb_s *_thumb_cb = g_new0(media_thumbnail_cb_s, 1);
 
-               ret = thumbnail_request_from_db_async(_media->request_id, _media->file_path, (ThumbFunc)__media_info_thumbnail_completed_cb, (void *)_thumb_cb, _content_get_uid());
-               ret = _content_error_capi(ret);
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       req_id++;
+       _media->request_id = req_id;
+
+       _thumb_cb->handle = _media;
+       _thumb_cb->user_data = user_data;
+       _thumb_cb->thumbnail_completed_cb = callback;
+
+       ret = thumbnail_request_from_db_async(_media->request_id, _media->file_path, (ThumbFunc)__media_info_thumbnail_completed_cb, (void *)_thumb_cb, _content_get_uid());
+       ret = _content_error_capi(ret);
 
        return ret;
 }
@@ -1993,28 +1733,25 @@ int media_info_generate_thumbnail(media_info_h media)
        char *thumb_path = NULL;
        media_info_s *_media = (media_info_s*)media;
 
-       if (_media != NULL && STRING_VALID(_media->media_id) && STRING_VALID(_media->file_path)) {
-               /* Already exists */
-               if (STRING_VALID(_media->thumbnail_path))
-                       return MEDIA_CONTENT_ERROR_NONE;
+       content_retip_if_fail(media);
+       content_retip_if_fail(STRING_VALID(_media->media_id));
+       content_retip_if_fail(STRING_VALID(_media->file_path));
 
-               ret = media_svc_create_thumbnail(_media->file_path, _media->media_type, _content_get_uid(), &thumb_path);
-               ret = _content_error_capi(ret);
-               if (ret == MEDIA_CONTENT_ERROR_UNSUPPORTED_CONTENT) {
-                       SAFE_FREE(thumb_path);
-                       return ret;
-               }
+       /* Already exists */
+       if (STRING_VALID(_media->thumbnail_path))
+               return MEDIA_CONTENT_ERROR_NONE;
 
-               /* thumb_path is not NULL except #MEDIA_CONTENT_ERROR_UNSUPPORTED_CONTENT */
-               _media->thumbnail_path = g_strdup(thumb_path);
-               SAFE_FREE(thumb_path);
-               if (_media->thumbnail_path == NULL)
-                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       ret = media_svc_create_thumbnail(_media->file_path, _media->media_type, _content_get_uid(), &thumb_path);
+       ret = _content_error_capi(ret);
+       if (ret == MEDIA_CONTENT_ERROR_UNSUPPORTED_CONTENT) {
+               g_free(thumb_path);
+               return ret;
        }
 
+       /* thumb_path is not NULL except #MEDIA_CONTENT_ERROR_UNSUPPORTED_CONTENT */
+       _media->thumbnail_path = g_strdup(thumb_path);
+       g_free(thumb_path);
+
        return ret;
 }
 
@@ -2046,26 +1783,26 @@ int media_info_start_face_detection(media_info_h media, media_face_detection_com
                return MEDIA_CONTENT_ERROR_NOT_SUPPORTED;
        }
 
-       if (_media != NULL && STRING_VALID(_media->media_id) && STRING_VALID(_media->file_path)) {
-               if (g_strcmp0(_media->mime_type, "image/jpeg") != 0 && g_strcmp0(_media->mime_type, "image/png") != 0 && g_strcmp0(_media->mime_type, "image/bmp") != 0) {
-                       content_error("Unsupported mime type");
-                       return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-               }
+       content_retip_if_fail(media);
+       content_retip_if_fail(STRING_VALID(_media->media_id));
+       content_retip_if_fail(STRING_VALID(_media->file_path));
+       content_retip_if_fail(callback);
 
-               media_face_cb_s *_face_cb = (media_face_cb_s*)calloc(1, sizeof(media_face_cb_s));
-               content_retvm_if(_face_cb == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-               req_id++;
-               _media->face_request_id = req_id;
+       if (g_strcmp0(_media->mime_type, "image/jpeg") != 0 && g_strcmp0(_media->mime_type, "image/png") != 0 && g_strcmp0(_media->mime_type, "image/bmp") != 0) {
+               content_error("Unsupported mime type");
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
 
-               _face_cb->user_data = user_data;
-               _face_cb->face_completed_cb = callback;
+       media_face_cb_s *_face_cb = g_new0(media_face_cb_s, 1);
 
-               ret = dcm_request_extract_face_async(_media->face_request_id, _media->file_path, (FaceFunc)__media_info_face_completed_cb, (void *)_face_cb, _content_get_uid());
-               ret = _content_error_capi(ret);
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       req_id++;
+       _media->face_request_id = req_id;
+
+       _face_cb->user_data = user_data;
+       _face_cb->face_completed_cb = callback;
+
+       ret = dcm_request_extract_face_async(_media->face_request_id, _media->file_path, (FaceFunc)__media_info_face_completed_cb, (void *)_face_cb, _content_get_uid());
+       ret = _content_error_capi(ret);
 
        return ret;
 }
@@ -2093,25 +1830,15 @@ int media_info_cancel_face_detection(media_info_h media)
 
 int media_info_set_description(media_info_h media, const char *description)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        content_warn("DEPRECATION WARNING: media_info_set_description() is deprecated and will be removed from next release.");
        media_info_s *_media = (media_info_s*)media;
 
-       if (_media != NULL) {
-               SAFE_FREE(_media->description);
+       content_retip_if_fail(media);
 
-               if (STRING_VALID(description)) {
-                       _media->description = strdup(description);
-                       content_retvm_if(_media->description == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-               } else {
-                       _media->description = NULL;
-               }
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       g_free(_media->description);
+       _media->description = g_strdup(description);
 
-       return ret;
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_info_set_longitude(media_info_h media, double longitude)
index 172bbbb..3d76b6f 100755 (executable)
 static void __media_playlist_item_free(gpointer item)
 {
        media_playlist_item_s *_item = (media_playlist_item_s *)item;
-       SAFE_FREE(_item->media_id);
-       SAFE_FREE(_item->playlist_name);
-       SAFE_FREE(_item->thumbnail_path);
-       SAFE_FREE(_item);
+
+       g_free(_item->media_id);
+       g_free(_item->playlist_name);
+       g_free(_item->thumbnail_path);
+       g_free(_item);
 }
 
 static void __media_playlist_item_release(media_playlist_s *playlist)
@@ -226,13 +227,13 @@ int media_playlist_insert_to_db(const char *name, media_playlist_h *playlist)
        int playlist_id = 0;
 
        content_retip_if_fail(STRING_VALID(name));
+       content_retip_if_fail(playlist);
 
-       media_playlist_s *_playlist = (media_playlist_s *)calloc(1, sizeof(media_playlist_s));
-       content_retvm_if(_playlist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+       media_playlist_s *_playlist = g_new0(media_playlist_s, 1);
 
        ret = __media_playlist_insert_playlist_record(name, &playlist_id);
        if (ret != MEDIA_CONTENT_ERROR_NONE) {
-               SAFE_FREE(_playlist);
+               g_free(_playlist);
                return ret;
        }
 
@@ -292,11 +293,12 @@ int media_playlist_foreach_media_from_db(int playlist_id, filter_h filter, playl
 int media_playlist_destroy(media_playlist_h playlist)
 {
        media_playlist_s *_playlist = (media_playlist_s *)playlist;
+
        content_retip_if_fail(playlist);
 
-       SAFE_FREE(_playlist->name);
-       SAFE_FREE(_playlist->thumbnail_path);
-       SAFE_FREE(_playlist);
+       g_free(_playlist->name);
+       g_free(_playlist->thumbnail_path);
+       g_free(_playlist);
 
        return MEDIA_CONTENT_ERROR_NONE;
 }
@@ -304,10 +306,11 @@ int media_playlist_destroy(media_playlist_h playlist)
 int media_playlist_clone(media_playlist_h *dst, media_playlist_h src)
 {
        media_playlist_s *_src = (media_playlist_s *)src;
-       content_retip_if_fail(_src);
 
-       media_playlist_s *_dst = (media_playlist_s *)calloc(1, sizeof(media_playlist_s));
-       content_retvm_if(_dst == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+       content_retip_if_fail(dst);
+       content_retip_if_fail(src);
+
+       media_playlist_s *_dst = g_new0(media_playlist_s, 1);
 
        _dst->playlist_id = _src->playlist_id;
        _dst->name = g_strdup(_src->name);
@@ -324,6 +327,7 @@ int media_playlist_get_playlist_from_db(int playlist_id, media_playlist_h *playl
        char *query = NULL;
 
        content_retipm_if_fail(playlist_id > 0, "%d", playlist_id);
+       content_retip_if_fail(playlist);
 
        query = sqlite3_mprintf(SELECT_PLAYLIST_FROM_PLAYLIST, playlist_id);
 
@@ -334,12 +338,7 @@ int media_playlist_get_playlist_from_db(int playlist_id, media_playlist_h *playl
        media_playlist_s *_playlist = NULL;
 
        if (sqlite3_step(stmt) == SQLITE_ROW) {
-               _playlist = (media_playlist_s *)calloc(1, sizeof(media_playlist_s));
-               if (_playlist == NULL) {
-                       content_error("Out of memory");
-                       SQLITE3_FINALIZE(stmt);
-                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-               }
+               _playlist = g_new0(media_playlist_s, 1);
 
                _playlist->playlist_id = playlist_id;
                _playlist->name = g_strdup((const char *)sqlite3_column_text(stmt, 0));
@@ -359,6 +358,7 @@ int media_playlist_get_playlist_from_db(int playlist_id, media_playlist_h *playl
 int media_playlist_get_playlist_id(media_playlist_h playlist, int *playlist_id)
 {
        media_playlist_s *_playlist = (media_playlist_s *)playlist;
+
        content_retip_if_fail(playlist);
        content_retip_if_fail(playlist_id);
 
@@ -370,6 +370,7 @@ int media_playlist_get_playlist_id(media_playlist_h playlist, int *playlist_id)
 int media_playlist_get_name(media_playlist_h playlist, char **name)
 {
        media_playlist_s *_playlist = (media_playlist_s *)playlist;
+
        content_retip_if_fail(playlist);
        content_retip_if_fail(name);
 
@@ -381,6 +382,7 @@ int media_playlist_get_name(media_playlist_h playlist, char **name)
 int media_playlist_get_thumbnail_path(media_playlist_h playlist, char **path)
 {
        media_playlist_s *_playlist = (media_playlist_s *)playlist;
+
        content_retip_if_fail(playlist);
        content_retip_if_fail(path);
 
@@ -421,10 +423,9 @@ int media_playlist_set_name(media_playlist_h playlist, const char *playlist_name
        content_retip_if_fail(playlist);
        content_retip_if_fail(STRING_VALID(playlist_name));
 
-       SAFE_FREE(_playlist->name);
+       g_free(_playlist->name);
 
-       item = (media_playlist_item_s *)calloc(1, sizeof(media_playlist_item_s));
-       content_retvm_if(item == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+       item = g_new0(media_playlist_item_s, 1);
 
        item->playlist_name = g_strdup(playlist_name);
        item->function = MEDIA_PLAYLIST_UPDATE_PLAYLIST_NAME;
@@ -443,10 +444,9 @@ int media_playlist_set_thumbnail_path(media_playlist_h playlist, const char *pat
        content_retip_if_fail(playlist);
        content_retip_if_fail(STRING_VALID(path));
 
-       SAFE_FREE(_playlist->thumbnail_path);
+       g_free(_playlist->thumbnail_path);
 
-       item = (media_playlist_item_s *)calloc(1, sizeof(media_playlist_item_s));
-       content_retvm_if(item == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+       item = g_new0(media_playlist_item_s, 1);
 
        item->thumbnail_path = g_strdup(path);
        item->function = MEDIA_PLAYLIST_UPDATE_THUMBNAIL_PATH;
@@ -466,8 +466,7 @@ int media_playlist_set_play_order(media_playlist_h playlist, int playlist_member
        content_retipm_if_fail(playlist_member_id > 0, "%d", playlist_member_id);
        content_retipm_if_fail(play_order >= 0, "%d", play_order);
 
-       item = (media_playlist_item_s *)calloc(1, sizeof(media_playlist_item_s));
-       content_retvm_if(item == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+       item = g_new0(media_playlist_item_s, 1);
 
        item->playlist_member_id = playlist_member_id;
        item->function = MEDIA_PLAYLIST_UPDATE_PLAY_ORDER;
@@ -486,8 +485,7 @@ int media_playlist_add_media(media_playlist_h playlist, const char *media_id)
        content_retip_if_fail(playlist);
        content_retip_if_fail(STRING_VALID(media_id));
 
-       item = (media_playlist_item_s *)calloc(1, sizeof(media_playlist_item_s));
-       content_retvm_if(item == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+       item = g_new0(media_playlist_item_s, 1);
 
        item->media_id = g_strdup(media_id);
        item->function = MEDIA_PLAYLIST_ADD;
@@ -505,8 +503,7 @@ int media_playlist_remove_media(media_playlist_h playlist, int playlist_member_i
        content_retip_if_fail(playlist);
        content_retipm_if_fail(playlist_member_id > 0, "%d", playlist_member_id);
 
-       item = (media_playlist_item_s *)calloc(1, sizeof(media_playlist_item_s));
-       content_retvm_if(item == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+       item = g_new0(media_playlist_item_s, 1);
 
        item->playlist_member_id = playlist_member_id;
        item->function = MEDIA_PLAYLIST_REMOVE;
@@ -576,7 +573,9 @@ static int __media_playlist_get_media_id_by_path(const char *path, char **media_
        int ret = MEDIA_CONTENT_ERROR_NONE;
        char *query = NULL;
        sqlite3_stmt *stmt = NULL;
+
        content_retip_if_fail(path);
+       content_retip_if_fail(media_id);
 
 #ifdef _USE_TVPD_MODE
        query = sqlite3_mprintf("SELECT media_id FROM '%q' WHERE media_path='%q'", DB_VIEW_MEDIA, path);
@@ -688,8 +687,7 @@ int media_playlist_create(media_playlist_h *playlist)
 {
        content_retip_if_fail(playlist);
 
-       media_playlist_s *_playlist = (media_playlist_s *)calloc(1, sizeof(media_playlist_s));
-       content_retvm_if(_playlist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+       media_playlist_s *_playlist = g_new0(media_playlist_s, 1);
 
        _playlist->playlist_id = -1;
        _playlist->name = NULL;
index eb8fa7c..fee2cfb 100755 (executable)
@@ -53,20 +53,20 @@ int media_pvr_destroy(media_pvr_h pvr)
        int ret = MEDIA_CONTENT_ERROR_NONE;
        media_pvr_s *_pvr = (media_pvr_s*)pvr;
        if (_pvr) {
-               SAFE_FREE(_pvr->media_id);
-               SAFE_FREE(_pvr->storage_id);
-               SAFE_FREE(_pvr->channel_name);
-               SAFE_FREE(_pvr->channel_num);
-               SAFE_FREE(_pvr->program_title);
-               SAFE_FREE(_pvr->program_crid);
-               SAFE_FREE(_pvr->guidance);
-               SAFE_FREE(_pvr->synopsis);
-               SAFE_FREE(_pvr->genre);
-               SAFE_FREE(_pvr->language);
-               SAFE_FREE(_pvr->path);
-               SAFE_FREE(_pvr->modified_month);
-               SAFE_FREE(_pvr->private_data);
-               SAFE_FREE(_pvr);
+               g_free(_pvr->media_id);
+               g_free(_pvr->storage_id);
+               g_free(_pvr->channel_name);
+               g_free(_pvr->channel_num);
+               g_free(_pvr->program_title);
+               g_free(_pvr->program_crid);
+               g_free(_pvr->guidance);
+               g_free(_pvr->synopsis);
+               g_free(_pvr->genre);
+               g_free(_pvr->language);
+               g_free(_pvr->path);
+               g_free(_pvr->modified_month);
+               g_free(_pvr->private_data);
+               g_free(_pvr);
 
                ret = MEDIA_CONTENT_ERROR_NONE;
        } else {
@@ -79,176 +79,64 @@ int media_pvr_destroy(media_pvr_h pvr)
 
 int media_pvr_clone(media_pvr_h *dst, media_pvr_h src)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_pvr_s *_src = (media_pvr_s*)src;
 
-       if (_src != NULL) {
-               media_pvr_s *_dst = (media_pvr_s*)calloc(1, sizeof(media_pvr_s));
-               if (_dst == NULL) {
-                       content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-               }
-
-               if (STRING_VALID(_src->media_id)) {
-                       _dst->media_id = strdup(_src->media_id);
-                       if (_dst->media_id == NULL) {
-                               media_pvr_destroy((media_pvr_h)_dst);
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               }
-
-               if (STRING_VALID(_src->channel_name)) {
-                       _dst->channel_name = strdup(_src->channel_name);
-                       if (_dst->channel_name == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               media_pvr_destroy((media_pvr_h)_dst);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               }
-
-               if (STRING_VALID(_src->channel_num)) {
-                       _dst->channel_num = strdup(_src->channel_num);
-                       if (_dst->channel_num == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               media_pvr_destroy((media_pvr_h)_dst);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               }
-
-               if (STRING_VALID(_src->program_title)) {
-                       _dst->program_title = strdup(_src->program_title);
-                       if (_dst->program_title == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               media_pvr_destroy((media_pvr_h)_dst);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               }
-
-               if (STRING_VALID(_src->program_crid)) {
-                       _dst->program_crid = strdup(_src->program_crid);
-                       if (_dst->program_crid == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               media_pvr_destroy((media_pvr_h)_dst);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               }
-
-               if (STRING_VALID(_src->guidance)) {
-                       _dst->guidance = strdup(_src->guidance);
-                       if (_dst->guidance == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               media_pvr_destroy((media_pvr_h)_dst);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               }
-
-               if (STRING_VALID(_src->synopsis)) {
-                       _dst->synopsis = strdup(_src->synopsis);
-                       if (_dst->synopsis == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               media_pvr_destroy((media_pvr_h)_dst);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               }
-
-               if (STRING_VALID(_src->genre)) {
-                       _dst->genre = strdup(_src->genre);
-                       if (_dst->genre == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               media_pvr_destroy((media_pvr_h)_dst);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               }
-
-               if (STRING_VALID(_src->language)) {
-                       _dst->language = strdup(_src->language);
-                       if (_dst->language == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               media_pvr_destroy((media_pvr_h)_dst);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               }
-
-               if (STRING_VALID(_src->path)) {
-                       _dst->path = strdup(_src->path);
-                       if (_dst->path == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               media_pvr_destroy((media_pvr_h)_dst);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               }
-
-               if (STRING_VALID(_src->storage_id)) {
-                       _dst->storage_id = strdup(_src->storage_id);
-                       if (_dst->storage_id == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               media_pvr_destroy((media_pvr_h)_dst);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               }
-
-               if (STRING_VALID(_src->modified_month)) {
-                       _dst->modified_month = strdup(_src->modified_month);
-                       if (_dst->modified_month == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               media_pvr_destroy((media_pvr_h)_dst);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               }
-
-               if (STRING_VALID(_src->private_data)) {
-                       _dst->private_data = strdup(_src->private_data);
-                       if (_dst->private_data == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               media_pvr_destroy((media_pvr_h)_dst);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               }
-               _dst->duration = _src->duration;
-               _dst->timezone = _src->timezone;
-               _dst->ptc = _src->ptc;
-               _dst->major = _src->major;
-               _dst->minor = _src->minor;
-               _dst->channel_type = _src->channel_type;
-               _dst->program_num = _src->program_num;
-               _dst->service_profile = _src->service_profile;
-               _dst->timer_record = _src->timer_record;
-               _dst->series_record = _src->series_record;
-               _dst->hd = _src->hd;
-               _dst->subtitle = _src->subtitle;
-               _dst->ttx = _src->ttx;
-               _dst->ad = _src->ad;
-               _dst->hard_of_hearing_radio = _src->hard_of_hearing_radio;
-               _dst->data_service = _src->data_service;
-               _dst->content_lock = _src->content_lock;
-               _dst->embargo_time = _src->embargo_time;
-               _dst->expiry_time = _src->expiry_time;
-               _dst->size = _src->size;
-               _dst->parental_rating = _src->parental_rating;
-               _dst->start_time = _src->start_time;
-               _dst->program_start_time = _src->program_start_time;
-               _dst->program_end_time = _src->program_end_time;
-               _dst->program_date = _src->program_date;
-               _dst->content_watch = _src->content_watch;
-               _dst->has_audio_only = _src->has_audio_only;
-               _dst->is_local_record = _src->is_local_record;
-               _dst->resolution = _src->resolution;
-               _dst->aspectratio = _src->aspectratio;
-               _dst->sports_type = _src->sports_type;
-               _dst->guidance_length = _src->guidance_length;
-               _dst->tvmode = _src->tvmode;
-               _dst->play_count = _src->play_count;
-
-               *dst = (media_pvr_h)_dst;
-
-               ret = MEDIA_CONTENT_ERROR_NONE;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
-
-       return ret;
+       content_retip_if_fail(dst);
+       content_retip_if_fail(src);
+
+       media_pvr_s *_dst = g_new0(media_pvr_s, 1);
+
+       _dst->media_id = g_strdup(_src->media_id);
+       _dst->channel_name = g_strdup(_src->channel_name);
+       _dst->channel_num = g_strdup(_src->channel_num);
+       _dst->program_title = g_strdup(_src->program_title);
+       _dst->program_crid = g_strdup(_src->program_crid);
+       _dst->guidance = g_strdup(_src->guidance);
+       _dst->synopsis = g_strdup(_src->synopsis);
+       _dst->genre = g_strdup(_src->genre);
+       _dst->language = g_strdup(_src->language);
+       _dst->path = g_strdup(_src->path);
+       _dst->storage_id = g_strdup(_src->storage_id);
+       _dst->modified_month = g_strdup(_src->modified_month);
+       _dst->private_data = g_strdup(_src->private_data);
+       _dst->duration = _src->duration;
+       _dst->timezone = _src->timezone;
+       _dst->ptc = _src->ptc;
+       _dst->major = _src->major;
+       _dst->minor = _src->minor;
+       _dst->channel_type = _src->channel_type;
+       _dst->program_num = _src->program_num;
+       _dst->service_profile = _src->service_profile;
+       _dst->timer_record = _src->timer_record;
+       _dst->series_record = _src->series_record;
+       _dst->hd = _src->hd;
+       _dst->subtitle = _src->subtitle;
+       _dst->ttx = _src->ttx;
+       _dst->ad = _src->ad;
+       _dst->hard_of_hearing_radio = _src->hard_of_hearing_radio;
+       _dst->data_service = _src->data_service;
+       _dst->content_lock = _src->content_lock;
+       _dst->embargo_time = _src->embargo_time;
+       _dst->expiry_time = _src->expiry_time;
+       _dst->size = _src->size;
+       _dst->parental_rating = _src->parental_rating;
+       _dst->start_time = _src->start_time;
+       _dst->program_start_time = _src->program_start_time;
+       _dst->program_end_time = _src->program_end_time;
+       _dst->program_date = _src->program_date;
+       _dst->content_watch = _src->content_watch;
+       _dst->has_audio_only = _src->has_audio_only;
+       _dst->is_local_record = _src->is_local_record;
+       _dst->resolution = _src->resolution;
+       _dst->aspectratio = _src->aspectratio;
+       _dst->sports_type = _src->sports_type;
+       _dst->guidance_length = _src->guidance_length;
+       _dst->tvmode = _src->tvmode;
+       _dst->play_count = _src->play_count;
+
+       *dst = (media_pvr_h)_dst;
+
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_pvr_get_pvr_from_db(const char *media_id, media_pvr_h *pvr)
@@ -271,13 +159,7 @@ int media_pvr_get_pvr_from_db(const char *media_id, media_pvr_h *pvr)
        media_pvr_s *_pvr = NULL;
 
        if (sqlite3_step(stmt) == SQLITE_ROW) {
-               _pvr = (media_pvr_s*)calloc(1, sizeof(media_pvr_s));
-
-               if (_pvr == NULL) {
-                       content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                       SQLITE3_FINALIZE(stmt);
-                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-               }
+               _pvr = g_new0(media_pvr_s, 1);
 
                _media_pvr_item_get_detail(stmt, (media_pvr_h)_pvr);
 
@@ -294,277 +176,134 @@ int media_pvr_get_pvr_from_db(const char *media_id, media_pvr_h *pvr)
 
 int media_pvr_get_media_id(media_pvr_h pvr, char **media_id)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_pvr_s *_pvr = (media_pvr_s*)pvr;
 
-       if (_pvr && media_id) {
-               if (STRING_VALID(_pvr->media_id)) {
-                       *media_id = strdup(_pvr->media_id);
-                       if (*media_id == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               } else {
-                       *media_id = NULL;
-               }
+       content_retip_if_fail(pvr);
+       content_retip_if_fail(media_id);
 
-               ret = MEDIA_CONTENT_ERROR_NONE;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       *media_id = g_strdup(_pvr->media_id);
 
-       return ret;
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_pvr_get_channel_name(media_pvr_h pvr, char **channel_name)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_pvr_s *_pvr = (media_pvr_s*)pvr;
 
-       if (_pvr && channel_name) {
-               if (STRING_VALID(_pvr->channel_name)) {
-                       *channel_name = strdup(_pvr->channel_name);
-                       if (*channel_name == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               } else {
-                       *channel_name = NULL;
-               }
+       content_retip_if_fail(pvr);
+       content_retip_if_fail(channel_name);
 
-               ret = MEDIA_CONTENT_ERROR_NONE;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       *channel_name = g_strdup(_pvr->channel_name);
 
-       return ret;
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_pvr_get_channel_num(media_pvr_h pvr, char **channel_num)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_pvr_s *_pvr = (media_pvr_s*)pvr;
 
-       if (_pvr && channel_num) {
-               if (STRING_VALID(_pvr->channel_num)) {
-                       *channel_num = strdup(_pvr->channel_num);
-                       if (*channel_num == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               } else {
-                       *channel_num = NULL;
-               }
+       content_retip_if_fail(pvr);
+       content_retip_if_fail(channel_num);
 
-               ret = MEDIA_CONTENT_ERROR_NONE;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       *channel_num = g_strdup(_pvr->channel_num);
 
-       return ret;
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_pvr_get_program_title(media_pvr_h pvr, char **program_title)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_pvr_s *_pvr = (media_pvr_s*)pvr;
 
-       if (_pvr && program_title) {
-               if (STRING_VALID(_pvr->program_title)) {
-                       *program_title = strdup(_pvr->program_title);
-                       if (*program_title == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               } else {
-                       *program_title = NULL;
-               }
+       content_retip_if_fail(pvr);
+       content_retip_if_fail(program_title);
 
-               ret = MEDIA_CONTENT_ERROR_NONE;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       *program_title = g_strdup(_pvr->program_title);
 
-       return ret;
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_pvr_get_program_crid(media_pvr_h pvr, char **program_crid)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_pvr_s *_pvr = (media_pvr_s*)pvr;
 
-       if (_pvr && program_crid) {
-               if (STRING_VALID(_pvr->program_crid)) {
-                       *program_crid = strdup(_pvr->program_crid);
-                       if (*program_crid == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               } else {
-                       *program_crid = NULL;
-               }
+       content_retip_if_fail(pvr);
+       content_retip_if_fail(program_crid);
 
-               ret = MEDIA_CONTENT_ERROR_NONE;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       *program_crid = g_strdup(_pvr->program_crid);
 
-       return ret;
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_pvr_get_guidance(media_pvr_h pvr, char **guidance)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_pvr_s *_pvr = (media_pvr_s*)pvr;
 
-       if (_pvr && guidance) {
-               if (STRING_VALID(_pvr->guidance)) {
-                       *guidance = strdup(_pvr->guidance);
-                       if (*guidance == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               } else {
-                       *guidance = NULL;
-               }
+       content_retip_if_fail(pvr);
+       content_retip_if_fail(guidance);
 
-               ret = MEDIA_CONTENT_ERROR_NONE;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       *guidance = g_strdup(_pvr->guidance);
 
-       return ret;
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_pvr_get_synopsis(media_pvr_h pvr, char **synopsis)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_pvr_s *_pvr = (media_pvr_s*)pvr;
 
-       if (_pvr && synopsis) {
-               if (STRING_VALID(_pvr->synopsis)) {
-                       *synopsis = strdup(_pvr->synopsis);
-                       if (*synopsis == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               } else {
-                       *synopsis = NULL;
-               }
+       content_retip_if_fail(pvr);
+       content_retip_if_fail(synopsis);
 
-               ret = MEDIA_CONTENT_ERROR_NONE;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       *synopsis = g_strdup(_pvr->synopsis);
 
-       return ret;
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_pvr_get_genre(media_pvr_h pvr, char **genre)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_pvr_s *_pvr = (media_pvr_s*)pvr;
 
-       if (_pvr && genre) {
-               if (STRING_VALID(_pvr->genre)) {
-                       *genre = strdup(_pvr->genre);
-                       if (*genre == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               } else {
-                       *genre = NULL;
-               }
+       content_retip_if_fail(pvr);
+       content_retip_if_fail(genre);
 
-               ret = MEDIA_CONTENT_ERROR_NONE;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       *genre = g_strdup(_pvr->genre);
 
-       return ret;
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_pvr_get_language(media_pvr_h pvr, char **language)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_pvr_s *_pvr = (media_pvr_s*)pvr;
 
-       if (_pvr && language) {
-               if (STRING_VALID(_pvr->language)) {
-                       *language = strdup(_pvr->language);
-                       if (*language == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               } else {
-                       *language = NULL;
-               }
+       content_retip_if_fail(pvr);
+       content_retip_if_fail(language);
 
-               ret = MEDIA_CONTENT_ERROR_NONE;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       *language = g_strdup(_pvr->language);
 
-       return ret;
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_pvr_get_path(media_pvr_h pvr, char **path)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_pvr_s *_pvr = (media_pvr_s*)pvr;
 
-       if (_pvr && path) {
-               if (STRING_VALID(_pvr->path)) {
-                       *path = strdup(_pvr->path);
-                       if (*path == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               } else {
-                       *path = NULL;
-               }
+       content_retip_if_fail(pvr);
+       content_retip_if_fail(path);
 
-               ret = MEDIA_CONTENT_ERROR_NONE;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       *path = g_strdup(_pvr->path);
 
-       return ret;
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_pvr_get_storage_id(media_pvr_h pvr, char **storage_id)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_pvr_s *_pvr = (media_pvr_s*)pvr;
 
-       if (_pvr && storage_id) {
-               if (STRING_VALID(_pvr->storage_id)) {
-                       *storage_id = strdup(_pvr->storage_id);
-                       if (*storage_id == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               } else {
-                       *storage_id = NULL;
-               }
+       content_retip_if_fail(pvr);
+       content_retip_if_fail(storage_id);
 
-               ret = MEDIA_CONTENT_ERROR_NONE;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       *storage_id = g_strdup(_pvr->storage_id);
 
-       return ret;
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_pvr_get_size(media_pvr_h pvr, unsigned long long *size)
@@ -1049,27 +788,14 @@ int media_pvr_get_aspectratio(media_pvr_h pvr, media_pvr_aspectratio_e* aspectra
 
 int media_pvr_get_modified_month(media_pvr_h pvr, char **modified_month)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_pvr_s *_pvr = (media_pvr_s*)pvr;
 
-       if (_pvr && modified_month) {
-               if (STRING_VALID(_pvr->modified_month)) {
-                       *modified_month = strdup(_pvr->modified_month);
-                       if (*modified_month == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               } else {
-                       *modified_month = NULL;
-               }
+       content_retip_if_fail(pvr);
+       content_retip_if_fail(modified_month);
 
-               ret = MEDIA_CONTENT_ERROR_NONE;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       *modified_month = g_strdup(_pvr->modified_month);
 
-       return ret;
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_pvr_get_sports_type(media_pvr_h pvr, int* sports_type)
@@ -1141,24 +867,12 @@ int media_pvr_get_private_data(media_pvr_h pvr, char **private_data)
        int ret = MEDIA_CONTENT_ERROR_NONE;
        media_pvr_s *_pvr = (media_pvr_s*)pvr;
 
-       if (_pvr && private_data) {
-               if (STRING_VALID(_pvr->private_data)) {
-                       *private_data = strdup(_pvr->private_data);
-                       if (*private_data == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               } else {
-                       *private_data = NULL;
-               }
+       content_retip_if_fail(pvr);
+       content_retip_if_fail(private_data);
 
-               ret = MEDIA_CONTENT_ERROR_NONE;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       *private_data = g_strdup(_pvr->private_data);
 
-       return ret;
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_pvr_get_highlight(media_pvr_h pvr, bool *highlight)
@@ -1194,22 +908,15 @@ int media_pvr_set_play_count(media_pvr_h pvr, int play_count)
 
 int media_pvr_set_program_title(media_pvr_h pvr, const char *program_title)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_pvr_s *_pvr = (media_pvr_s*)pvr;
 
-       if (_pvr != NULL && STRING_VALID(program_title)) {
-               SAFE_FREE(_pvr->program_title);
-               _pvr->program_title = strdup(program_title);
-               if (_pvr->program_title == NULL) {
-                       content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-               }
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       content_retip_if_fail(pvr);
+       content_retip_if_fail(STRING_VALID(program_title));
 
-       return ret;
+       g_free(_pvr->program_title);
+       _pvr->program_title = g_strdup(program_title);
+
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_pvr_set_content_lock(media_pvr_h pvr, bool content_lock)
index 7a30d04..8014422 100755 (executable)
@@ -25,10 +25,8 @@ int media_storage_get_storage_info_from_db(const char *storage_id, media_storage
        sqlite3_stmt *stmt = NULL;
        media_storage_s *_storage = NULL;
 
-       if (!STRING_VALID(storage_id) || (storage == NULL)) {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       content_retip_if_fail(STRING_VALID(storage_id));
+       content_retip_if_fail(storage);
 
        snprintf(select_query, sizeof(select_query), SELECT_STORAGE_INFO_FROM_STORAGE, storage_id);
 
@@ -36,13 +34,7 @@ int media_storage_get_storage_info_from_db(const char *storage_id, media_storage
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        if (sqlite3_step(stmt) == SQLITE_ROW) {
-               _storage = (media_storage_s*)calloc(1, sizeof(media_storage_s));
-
-               if (_storage == NULL) {
-                       content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                       SQLITE3_FINALIZE(stmt);
-                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-               }
+               _storage = g_new0(media_storage_s, 1);
 
                _storage->storage_id = g_strdup(storage_id);
                _storage->storage_path = g_strdup((const char *)sqlite3_column_text(stmt, 0));
@@ -133,9 +125,9 @@ int media_storage_destroy(media_storage_h storage)
        content_warn("DEPRECATION WARNING: media_storage_destroy() is deprecated and will be removed from next release.");
        media_storage_s *_storage = (media_storage_s*)storage;
        if (_storage) {
-               SAFE_FREE(_storage->storage_id);
-               SAFE_FREE(_storage->storage_path);
-               SAFE_FREE(_storage);
+               g_free(_storage->storage_id);
+               g_free(_storage->storage_path);
+               g_free(_storage);
 
                ret = MEDIA_CONTENT_ERROR_NONE;
        } else {
@@ -148,89 +140,47 @@ int media_storage_destroy(media_storage_h storage)
 
 int media_storage_clone(media_storage_h *dst, media_storage_h src)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        content_warn("DEPRECATION WARNING: media_storage_clone() is deprecated and will be removed from next release.");
        media_storage_s *_src = (media_storage_s*)src;
 
-       if (_src != NULL) {
-               media_storage_s *_dst = (media_storage_s*)calloc(1, sizeof(media_storage_s));
-               content_retvm_if(_dst == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-
-               if (STRING_VALID(_src->storage_id)) {
-                       _dst->storage_id = strdup(_src->storage_id);
-                       if (_dst->storage_id == NULL) {
-                               media_storage_destroy((media_storage_h)_dst);
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               }
+       content_retip_if_fail(dst);
+       content_retip_if_fail(src);
 
-               if (STRING_VALID(_src->storage_path)) {
-                       _dst->storage_path = strdup(_src->storage_path);
-                       if (_dst->storage_path == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               media_storage_destroy((media_storage_h)_dst);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               }
+       media_storage_s *_dst = g_new0(media_storage_s, 1);
 
-               _dst->storage_type = _src->storage_type;
+       _dst->storage_id = g_strdup(_src->storage_id);
+       _dst->storage_path = g_strdup(_src->storage_path);
+       _dst->storage_type = _src->storage_type;
 
-               *dst = (media_storage_h)_dst;
+       *dst = (media_storage_h)_dst;
 
-               ret = MEDIA_CONTENT_ERROR_NONE;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
-
-       return ret;
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_storage_get_id(media_storage_h storage, char **storage_id)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        content_warn("DEPRECATION WARNING: media_storage_get_id() is deprecated and will be removed from next release.");
        media_storage_s *_storage = (media_storage_s*)storage;
 
-       if (_storage && storage_id) {
-               if (STRING_VALID(_storage->storage_id)) {
-                       *storage_id = strdup(_storage->storage_id);
-                       content_retvm_if(*storage_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-               } else {
-                       *storage_id = NULL;
-               }
+       content_retip_if_fail(storage);
+       content_retip_if_fail(storage_id);
 
-               ret = MEDIA_CONTENT_ERROR_NONE;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       *storage_id = g_strdup(_storage->storage_id);
 
-       return ret;
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_storage_get_path(media_storage_h storage, char **storage_path)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        content_warn("DEPRECATION WARNING: media_storage_get_path() is deprecated and will be removed from next release.");
        media_storage_s *_storage = (media_storage_s*)storage;
 
-       if (_storage && storage_path) {
-               if (STRING_VALID(_storage->storage_path)) {
-                       *storage_path = strdup(_storage->storage_path);
-                       content_retvm_if(*storage_path == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-               } else {
-                       *storage_path = NULL;
-               }
+       content_retip_if_fail(storage);
+       content_retip_if_fail(storage_path);
 
-               ret = MEDIA_CONTENT_ERROR_NONE;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       *storage_path = g_strdup(_storage->storage_path);
 
-       return ret;
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_storage_get_type(media_storage_h storage, media_content_storage_e *storage_type)
index e572f51..9813de4 100755 (executable)
 static void __media_tag_item_free(gpointer item)
 {
        media_tag_item_s *_item = (media_tag_item_s *)item;
-       SAFE_FREE(_item->media_id);
-       SAFE_FREE(_item->tag_name);
-       SAFE_FREE(_item);
+
+       g_free(_item->media_id);
+       g_free(_item->tag_name);
+       g_free(_item);
 }
 
 static void __media_tag_item_release(media_tag_s *tag)
@@ -99,6 +100,7 @@ int media_tag_insert_to_db(const char *tag_name, media_tag_h *tag)
 {
        int ret = MEDIA_CONTENT_ERROR_NONE;
        char *query_str = NULL;
+       media_tag_s *_tag = NULL;
 
        content_retip_if_fail(STRING_VALID(tag_name));
        content_retip_if_fail(tag);
@@ -106,14 +108,12 @@ int media_tag_insert_to_db(const char *tag_name, media_tag_h *tag)
        query_str = sqlite3_mprintf(INSERT_TAG_TO_TAG, tag_name);
        ret = _content_query_sql(query_str);
        SQLITE3_SAFE_FREE(query_str);
+       content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "fail to insert tag");
 
-       if (ret == MEDIA_CONTENT_ERROR_NONE) {
-               media_tag_s *_tag = (media_tag_s *)calloc(1, sizeof(media_tag_s));
-               content_retvm_if(_tag == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+       _tag = g_new0(media_tag_s, 1);
 
-               ret = __media_tag_get_tag_info_from_db(tag_name, (media_tag_h)_tag);
-               *tag = (media_tag_h)_tag;
-       }
+       ret = __media_tag_get_tag_info_from_db(tag_name, (media_tag_h)_tag);
+       *tag = (media_tag_h)_tag;
 
        return ret;
 }
@@ -165,10 +165,11 @@ int media_tag_foreach_media_from_db(int tag_id, filter_h filter, media_info_cb c
 int media_tag_destroy(media_tag_h tag)
 {
        media_tag_s *_tag = (media_tag_s *)tag;
+
        content_retip_if_fail(tag);
 
-       SAFE_FREE(_tag->name);
-       SAFE_FREE(_tag);
+       g_free(_tag->name);
+       g_free(_tag);
 
        return MEDIA_CONTENT_ERROR_NONE;
 }
@@ -181,8 +182,7 @@ int media_tag_clone(media_tag_h *dst, media_tag_h src)
        content_retip_if_fail(src);
        content_retip_if_fail(dst);
 
-       _dst = (media_tag_s *)calloc(1, sizeof(media_tag_s));
-       content_retvm_if(_dst == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+       _dst = g_new0(media_tag_s, 1);
 
        _dst->tag_id = _src->tag_id;
        _dst->name = g_strdup(_src->name);
@@ -230,12 +230,7 @@ int media_tag_get_tag_from_db(int tag_id, media_tag_h *tag)
        content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
 
        if (sqlite3_step(stmt) == SQLITE_ROW) {
-               _tag = (media_tag_s *)calloc(1, sizeof(media_tag_s));
-               if (_tag == NULL) {
-                       SQLITE3_FINALIZE(stmt);
-                       content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-               }
+               _tag = g_new0(media_tag_s, 1);
 
                _tag->tag_id = tag_id;
                _tag->name = g_strdup((const char *)sqlite3_column_text(stmt, 0));
@@ -260,8 +255,7 @@ int media_tag_add_media(media_tag_h tag, const char *media_id)
        content_retip_if_fail(tag);
        content_retip_if_fail(STRING_VALID(media_id));
 
-       _item = (media_tag_item_s *)calloc(1, sizeof(media_tag_item_s));
-       content_retvm_if(_item == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+       _item = g_new0(media_tag_item_s, 1);
 
        _item->media_id = g_strdup(media_id);
        _item->function = MEDIA_TAG_ADD;
@@ -280,8 +274,7 @@ int media_tag_remove_media(media_tag_h tag, const char *media_id)
        content_retip_if_fail(tag);
        content_retip_if_fail(STRING_VALID(media_id));
 
-       _item = (media_tag_item_s *)calloc(1, sizeof(media_tag_item_s));
-       content_retvm_if(_item == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+       _item = g_new0(media_tag_item_s, 1);
 
        _item->media_id = g_strdup(media_id);
        _item->function = MEDIA_TAG_REMOVE;
@@ -300,10 +293,9 @@ int media_tag_set_name(media_tag_h tag, const char *tag_name)
        content_retip_if_fail(tag);
        content_retip_if_fail(STRING_VALID(tag_name));
 
-       SAFE_FREE(_tag->name);
+       g_free(_tag->name);
 
-       _item = (media_tag_item_s *)calloc(1, sizeof(media_tag_item_s));
-       content_retvm_if(_item == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+       _item = g_new0(media_tag_item_s, 1);
 
        _item->tag_name = g_strdup(tag_name);
        _item->function = MEDIA_TAG_UPDATE_TAG_NAME;
@@ -366,8 +358,7 @@ int media_tag_create(media_tag_h *tag)
 {
        content_retip_if_fail(tag);
 
-       media_tag_s *_tag = (media_tag_s *)calloc(1, sizeof(media_tag_s));
-       content_retvm_if(_tag == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+       media_tag_s *_tag = g_new0(media_tag_s, 1);
 
        _tag->tag_id = -1;
        _tag->name = NULL;
index 3a82690..d326be8 100755 (executable)
@@ -51,14 +51,14 @@ int media_uhd_destroy(media_uhd_h uhd)
        int ret = MEDIA_CONTENT_ERROR_NONE;
        media_uhd_s *_uhd = (media_uhd_s*)uhd;
        if (_uhd) {
-               SAFE_FREE(_uhd->media_id);
-               SAFE_FREE(_uhd->storage_id);
-               SAFE_FREE(_uhd->path);
-               SAFE_FREE(_uhd->content_id);
-               SAFE_FREE(_uhd->content_title);
-               SAFE_FREE(_uhd->file_name);
-               SAFE_FREE(_uhd->release_date);
-               SAFE_FREE(_uhd);
+               g_free(_uhd->media_id);
+               g_free(_uhd->storage_id);
+               g_free(_uhd->path);
+               g_free(_uhd->content_id);
+               g_free(_uhd->content_title);
+               g_free(_uhd->file_name);
+               g_free(_uhd->release_date);
+               g_free(_uhd);
 
                ret = MEDIA_CONTENT_ERROR_NONE;
        } else {
@@ -71,93 +71,29 @@ int media_uhd_destroy(media_uhd_h uhd)
 
 int media_uhd_clone(media_uhd_h *dst, media_uhd_h src)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_uhd_s *_src = (media_uhd_s*)src;
 
-       if (_src != NULL) {
-               media_uhd_s *_dst = (media_uhd_s*)calloc(1, sizeof(media_uhd_s));
-               if (_dst == NULL) {
-                       content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-               }
-
-               if (STRING_VALID(_src->media_id)) {
-                       _dst->media_id = strdup(_src->media_id);
-                       if (_dst->media_id == NULL) {
-                               media_uhd_destroy((media_uhd_h)_dst);
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               }
-
-               if (STRING_VALID(_src->storage_id)) {
-                       _dst->storage_id = strdup(_src->storage_id);
-                       if (_dst->storage_id == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               media_uhd_destroy((media_uhd_h)_dst);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               }
-
-               if (STRING_VALID(_src->path)) {
-                       _dst->path = strdup(_src->path);
-                       if (_dst->path == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               media_uhd_destroy((media_uhd_h)_dst);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               }
-
-               if (STRING_VALID(_src->content_id)) {
-                       _dst->content_id = strdup(_src->content_id);
-                       if (_dst->content_id == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               media_uhd_destroy((media_uhd_h)_dst);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               }
-
-               if (STRING_VALID(_src->content_title)) {
-                       _dst->content_title = strdup(_src->content_title);
-                       if (_dst->content_title == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               media_uhd_destroy((media_uhd_h)_dst);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               }
-
-               if (STRING_VALID(_src->release_date)) {
-                       _dst->release_date = strdup(_src->release_date);
-                       if (_dst->release_date == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               media_uhd_destroy((media_uhd_h)_dst);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               }
-
-               if (STRING_VALID(_src->file_name)) {
-                       _dst->file_name = strdup(_src->file_name);
-                       if (_dst->file_name == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               media_uhd_destroy((media_uhd_h)_dst);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               }
-
-               _dst->size = _src->size;
-               _dst->modified_time = _src->modified_time;
-               _dst->played_position = _src->played_position;
-               _dst->sub_type = _src->sub_type;
-               _dst->played_count = _src->played_count;
-               *dst = (media_uhd_h)_dst;
+       content_retip_if_fail(dst);
+       content_retip_if_fail(src);
 
-               ret = MEDIA_CONTENT_ERROR_NONE;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       media_uhd_s *_dst = g_new0(media_uhd_s, 1);
 
-       return ret;
+       _dst->media_id = g_strdup(_src->media_id);
+       _dst->storage_id = g_strdup(_src->storage_id);
+       _dst->path = g_strdup(_src->path);
+       _dst->content_id = g_strdup(_src->content_id);
+       _dst->content_title = g_strdup(_src->content_title);
+       _dst->release_date = g_strdup(_src->release_date);
+       _dst->file_name = g_strdup(_src->file_name);
+       _dst->size = _src->size;
+       _dst->modified_time = _src->modified_time;
+       _dst->played_position = _src->played_position;
+       _dst->sub_type = _src->sub_type;
+       _dst->played_count = _src->played_count;
+
+       *dst = (media_uhd_h)_dst;
+
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_uhd_get_uhd_from_db(const char *media_id, media_uhd_h *uhd)
@@ -180,13 +116,7 @@ int media_uhd_get_uhd_from_db(const char *media_id, media_uhd_h *uhd)
        media_uhd_s *_uhd = NULL;
 
        if (sqlite3_step(stmt) == SQLITE_ROW) {
-               _uhd = (media_uhd_s*)calloc(1, sizeof(media_uhd_s));
-
-               if (_uhd == NULL) {
-                       content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                       SQLITE3_FINALIZE(stmt);
-                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-               }
+               _uhd = g_new0(media_uhd_s, 1);
 
                _media_uhd_item_get_detail(stmt, (media_uhd_h)_uhd);
 
@@ -203,77 +133,38 @@ int media_uhd_get_uhd_from_db(const char *media_id, media_uhd_h *uhd)
 
 int media_uhd_get_media_id(media_uhd_h uhd, char **media_id)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_uhd_s *_uhd = (media_uhd_s*)uhd;
 
-       if (_uhd && media_id) {
-               if (STRING_VALID(_uhd->media_id)) {
-                       *media_id = strdup(_uhd->media_id);
-                       if (*media_id == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               } else {
-                       *media_id = NULL;
-               }
+       content_retip_if_fail(uhd);
+       content_retip_if_fail(media_id);
 
-               ret = MEDIA_CONTENT_ERROR_NONE;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       *media_id = g_strdup(_uhd->media_id);
 
-       return ret;
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_uhd_get_storage_id(media_uhd_h uhd, char **storage_id)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_uhd_s *_uhd = (media_uhd_s*)uhd;
 
-       if (_uhd && storage_id) {
-               if (STRING_VALID(_uhd->storage_id)) {
-                       *storage_id = strdup(_uhd->storage_id);
-                       if (*storage_id == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               } else {
-                       *storage_id = NULL;
-               }
+       content_retip_if_fail(uhd);
+       content_retip_if_fail(storage_id);
 
-               ret = MEDIA_CONTENT_ERROR_NONE;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       *storage_id = g_strdup(_uhd->storage_id);
 
-       return ret;
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_uhd_get_path(media_uhd_h uhd, char **path)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_uhd_s *_uhd = (media_uhd_s*)uhd;
 
-       if (_uhd && path) {
-               if (STRING_VALID(_uhd->path)) {
-                       *path = strdup(_uhd->path);
-                       if (*path == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               } else {
-                       *path = NULL;
-               }
+       content_retip_if_fail(uhd);
+       content_retip_if_fail(path);
 
-               ret = MEDIA_CONTENT_ERROR_NONE;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       *path = g_strdup(_uhd->path);
 
-       return ret;
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_uhd_get_size(media_uhd_h uhd, unsigned long long *size)
@@ -294,102 +185,50 @@ int media_uhd_get_size(media_uhd_h uhd, unsigned long long *size)
 
 int media_uhd_get_content_id(media_uhd_h uhd, char **content_id)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_uhd_s *_uhd = (media_uhd_s*)uhd;
 
-       if (_uhd && content_id) {
-               if (STRING_VALID(_uhd->content_id)) {
-                       *content_id = strdup(_uhd->content_id);
-                       if (*content_id == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               } else {
-                       *content_id = NULL;
-               }
+       content_retip_if_fail(uhd);
+       content_retip_if_fail(content_id);
 
-               ret = MEDIA_CONTENT_ERROR_NONE;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       *content_id = g_strdup(_uhd->content_id);
 
-       return ret;
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_uhd_get_content_title(media_uhd_h uhd, char **content_title)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_uhd_s *_uhd = (media_uhd_s*)uhd;
 
-       if (_uhd && content_title) {
-               if (STRING_VALID(_uhd->content_title)) {
-                       *content_title = strdup(_uhd->content_title);
-                       if (*content_title == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               } else {
-                       *content_title = NULL;
-               }
+       content_retip_if_fail(uhd);
+       content_retip_if_fail(content_title);
 
-               ret = MEDIA_CONTENT_ERROR_NONE;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       *content_title = g_strdup(_uhd->content_title);
 
-       return ret;
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_uhd_get_file_name(media_uhd_h uhd, char **file_name)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_uhd_s *_uhd = (media_uhd_s*)uhd;
 
-       if (_uhd && file_name) {
-               if (STRING_VALID(_uhd->file_name)) {
-                       *file_name = strdup(_uhd->file_name);
-                       if (*file_name == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               } else {
-                       *file_name = NULL;
-               }
+       content_retip_if_fail(uhd);
+       content_retip_if_fail(file_name);
 
-               ret = MEDIA_CONTENT_ERROR_NONE;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       *file_name = g_strdup(_uhd->file_name);
 
-       return ret;
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_uhd_get_release_date(media_uhd_h uhd, char **release_date)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_uhd_s *_uhd = (media_uhd_s*)uhd;
 
-       if (_uhd && release_date) {
-               if (STRING_VALID(_uhd->release_date)) {
-                       *release_date = strdup(_uhd->release_date);
-                       if (*release_date == NULL) {
-                               content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-                       }
-               } else {
-                       *release_date = NULL;
-               }
+       content_retip_if_fail(uhd);
+       content_retip_if_fail(release_date);
 
-               ret = MEDIA_CONTENT_ERROR_NONE;
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       *release_date = g_strdup(_uhd->release_date);
 
-       return ret;
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_uhd_get_modified_time(media_uhd_h uhd, time_t *modified_time)
@@ -473,42 +312,28 @@ int media_uhd_set_played_position(media_uhd_h uhd, int played_position)
 
 int media_uhd_set_content_title(media_uhd_h uhd, const char *content_title)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_uhd_s *_uhd = (media_uhd_s*)uhd;
 
-       if (_uhd != NULL && STRING_VALID(content_title)) {
-               SAFE_FREE(_uhd->content_title);
-               _uhd->content_title = strdup(content_title);
-               if (_uhd->content_title == NULL) {
-                       content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-               }
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       content_retip_if_fail(uhd);
+       content_retip_if_fail(STRING_VALID(content_title));
 
-       return ret;
+       g_free(_uhd->content_title);
+       _uhd->content_title = g_strdup(content_title);
+
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_uhd_set_release_date(media_uhd_h uhd, const char *release_date)
 {
-       int ret = MEDIA_CONTENT_ERROR_NONE;
        media_uhd_s *_uhd = (media_uhd_s*)uhd;
 
-       if (_uhd != NULL && STRING_VALID(release_date)) {
-               SAFE_FREE(_uhd->release_date);
-               _uhd->release_date = strdup(release_date);
-               if (_uhd->release_date == NULL) {
-                       content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
-                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-               }
-       } else {
-               content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-       }
+       content_retip_if_fail(uhd);
+       content_retip_if_fail(STRING_VALID(release_date));
 
-       return ret;
+       g_free(_uhd->release_date);
+       _uhd->release_date = g_strdup(release_date);
+
+       return MEDIA_CONTENT_ERROR_NONE;
 }
 
 int media_uhd_set_sub_type(media_uhd_h uhd, int sub_type)
index 2e1bfda..a0b6233 100755 (executable)
@@ -166,7 +166,7 @@ bool _media_util_is_ignorable_file(const char *path)
                content_error("symbolic link(directory)");
                content_sec_debug("path[%s] real[%s]", org_path, tmp_path);
                SAFE_FREE(tmp_path);
-               SAFE_FREE(org_path);
+               g_free(org_path);
                return true;
        }
 #else
@@ -177,7 +177,7 @@ bool _media_util_is_ignorable_file(const char *path)
                        content_error("symbolic link(directory)");
                        content_sec_debug("path[%s] real[%s]", org_path, tmp_path);
                        SAFE_FREE(tmp_path);
-                       SAFE_FREE(org_path);
+                       g_free(org_path);
                        return true;
                }
        } else {
@@ -185,13 +185,13 @@ bool _media_util_is_ignorable_file(const char *path)
                        content_error("symbolic link(directory)");
                        content_sec_debug("path[%s] real[%s]", org_path, tmp_path);
                        SAFE_FREE(tmp_path);
-                       SAFE_FREE(org_path);
+                       g_free(org_path);
                        return true;
                }
        }
 #endif
        SAFE_FREE(tmp_path);
-       SAFE_FREE(org_path);
+       g_free(org_path);
 
        return false;
 }
@@ -211,7 +211,7 @@ static bool __is_scan_ignore_exist(const char *path)
        if (result)
                content_error("scan ignore file exist [%s]", ignore_path);
 
-       SAFE_FREE(ignore_path);
+       g_free(ignore_path);
 
        return (bool)result;
 }
@@ -289,7 +289,7 @@ int _media_content_check_dir(const char *path)
                content_error("symbolic link(directory)");
                content_sec_debug("path[%s] real[%s]", origin, real);
                SAFE_FREE(real);
-               SAFE_FREE(origin);
+               g_free(origin);
                return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
        }
 #else
@@ -300,7 +300,7 @@ int _media_content_check_dir(const char *path)
                        content_error("symbolic link(directory)");
                        content_sec_debug("path[%s] real[%s]", origin, real);
                        SAFE_FREE(real);
-                       SAFE_FREE(origin);
+                       g_free(origin);
                        return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
                }
        } else {
@@ -308,14 +308,14 @@ int _media_content_check_dir(const char *path)
                        content_error("symbolic link(directory)");
                        content_sec_debug("path[%s] real[%s]", origin, real);
                        SAFE_FREE(real);
-                       SAFE_FREE(origin);
+                       g_free(origin);
                        return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
                }
        }
 #endif
 
        SAFE_FREE(real);
-       SAFE_FREE(origin);
+       g_free(origin);
 
        return MEDIA_CONTENT_ERROR_NONE;
 }
index 469f254..504973b 100755 (executable)
@@ -22,17 +22,17 @@ int video_meta_destroy(video_meta_h video)
        video_meta_s *_video = (video_meta_s*)video;
        content_retvm_if(!_video, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Video handle is null");
 
-       SAFE_FREE(_video->media_id);
-       SAFE_FREE(_video->album);
-       SAFE_FREE(_video->artist);
-       SAFE_FREE(_video->album_artist);
-       SAFE_FREE(_video->genre);
-       SAFE_FREE(_video->composer);
-       SAFE_FREE(_video->year);
-       SAFE_FREE(_video->recorded_date);
-       SAFE_FREE(_video->copyright);
-       SAFE_FREE(_video->track_num);
-       SAFE_FREE(_video);
+       g_free(_video->media_id);
+       g_free(_video->album);
+       g_free(_video->artist);
+       g_free(_video->album_artist);
+       g_free(_video->genre);
+       g_free(_video->composer);
+       g_free(_video->year);
+       g_free(_video->recorded_date);
+       g_free(_video->copyright);
+       g_free(_video->track_num);
+       g_free(_video);
 
        return MEDIA_CONTENT_ERROR_NONE;
 }
@@ -40,10 +40,11 @@ int video_meta_destroy(video_meta_h video)
 int video_meta_clone(video_meta_h *dst, video_meta_h src)
 {
        video_meta_s *_src = (video_meta_s*)src;
-       content_retvm_if(!_src, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Source handle is null");
 
-       video_meta_s *_dst = (video_meta_s*)calloc(1, sizeof(video_meta_s));
-       content_retvm_if(!_dst, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+       content_retip_if_fail(dst);
+       content_retip_if_fail(src);
+
+       video_meta_s *_dst = g_new(video_meta_s, 1);
 
        _dst->media_id = g_strdup(_src->media_id);
        _dst->album = g_strdup(_src->album);
@@ -69,7 +70,9 @@ int video_meta_clone(video_meta_h *dst, video_meta_h src)
 int video_meta_get_media_id(video_meta_h video, char **media_id)
 {
        video_meta_s *_video = (video_meta_s*)video;
-       content_retvm_if(!_video || !media_id, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+       content_retip_if_fail(video);
+       content_retip_if_fail(media_id);
 
        *media_id = g_strdup(_video->media_id);
 
@@ -79,7 +82,9 @@ int video_meta_get_media_id(video_meta_h video, char **media_id)
 int video_meta_get_album(video_meta_h video, char **album)
 {
        video_meta_s *_video = (video_meta_s*)video;
-       content_retvm_if(!_video || !album, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+       content_retip_if_fail(video);
+       content_retip_if_fail(album);
 
        *album = g_strdup(_video->album);
 
@@ -89,7 +94,9 @@ int video_meta_get_album(video_meta_h video, char **album)
 int video_meta_get_artist(video_meta_h video, char **artist)
 {
        video_meta_s *_video = (video_meta_s*)video;
-       content_retvm_if(!_video || !artist, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+       content_retip_if_fail(video);
+       content_retip_if_fail(artist);
 
        *artist = g_strdup(_video->artist);
 
@@ -99,7 +106,9 @@ int video_meta_get_artist(video_meta_h video, char **artist)
 int video_meta_get_album_artist(video_meta_h video, char **album_artist)
 {
        video_meta_s *_video = (video_meta_s*)video;
-       content_retvm_if(!_video || !album_artist, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+       content_retip_if_fail(video);
+       content_retip_if_fail(album_artist);
 
        *album_artist = g_strdup(_video->album_artist);
 
@@ -109,7 +118,9 @@ int video_meta_get_album_artist(video_meta_h video, char **album_artist)
 int video_meta_get_genre(video_meta_h video, char **genre)
 {
        video_meta_s *_video = (video_meta_s*)video;
-       content_retvm_if(!_video || !genre, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+       content_retip_if_fail(video);
+       content_retip_if_fail(genre);
 
        *genre = g_strdup(_video->genre);
 
@@ -119,7 +130,9 @@ int video_meta_get_genre(video_meta_h video, char **genre)
 int video_meta_get_composer(video_meta_h video, char **composer)
 {
        video_meta_s *_video = (video_meta_s*)video;
-       content_retvm_if(!_video || !composer, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+       content_retip_if_fail(video);
+       content_retip_if_fail(composer);
 
        *composer = g_strdup(_video->composer);
 
@@ -129,7 +142,9 @@ int video_meta_get_composer(video_meta_h video, char **composer)
 int video_meta_get_year(video_meta_h video, char **year)
 {
        video_meta_s *_video = (video_meta_s*)video;
-       content_retvm_if(!_video || !year, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+       content_retip_if_fail(video);
+       content_retip_if_fail(year);
 
        *year = g_strdup(_video->year);
 
@@ -139,7 +154,9 @@ int video_meta_get_year(video_meta_h video, char **year)
 int video_meta_get_recorded_date(video_meta_h video, char **recorded_date)
 {
        video_meta_s *_video = (video_meta_s*)video;
-       content_retvm_if(!_video || !recorded_date, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+       content_retip_if_fail(video);
+       content_retip_if_fail(recorded_date);
 
        *recorded_date = g_strdup(_video->recorded_date);
 
@@ -149,7 +166,9 @@ int video_meta_get_recorded_date(video_meta_h video, char **recorded_date)
 int video_meta_get_copyright(video_meta_h video, char **copyright)
 {
        video_meta_s *_video = (video_meta_s*)video;
-       content_retvm_if(!_video || !copyright, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+       content_retip_if_fail(video);
+       content_retip_if_fail(copyright);
 
        *copyright = g_strdup(_video->copyright);
 
@@ -159,7 +178,9 @@ int video_meta_get_copyright(video_meta_h video, char **copyright)
 int video_meta_get_track_num(video_meta_h video, char **track_num)
 {
        video_meta_s *_video = (video_meta_s*)video;
-       content_retvm_if(!_video || !track_num, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid parameter");
+
+       content_retip_if_fail(video);
+       content_retip_if_fail(track_num);
 
        *track_num = g_strdup(_video->track_num);