From: Minje Ahn Date: Tue, 25 Jul 2017 06:29:05 +0000 (+0900) Subject: Remove __media_svc_malloc_and_strncpy_with_size() X-Git-Tag: submit/tizen/20170728.070738~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F79%2F140479%2F1;p=platform%2Fcore%2Fmultimedia%2Flibmedia-service.git Remove __media_svc_malloc_and_strncpy_with_size() Use g_strdup instead of __media_svc_malloc_and_strncpy_with_size Change-Id: I34df062c9b2c4b933a792ff78c34857e0f0dcb4f Signed-off-by: Minje Ahn --- diff --git a/src/common/media-svc-util.c b/src/common/media-svc-util.c index 2aaf6b5..58574a6 100755 --- a/src/common/media-svc-util.c +++ b/src/common/media-svc-util.c @@ -204,29 +204,6 @@ int __media_svc_malloc_and_strncpy(char **dst, const char *src) return MS_MEDIA_ERR_NONE; } -int __media_svc_malloc_and_strncpy_with_size(char **dst, const char *src, int copysize) -{ - if (!STRING_VALID(src)) { - media_svc_error("invalid src"); - return MS_MEDIA_ERR_INVALID_PARAMETER; - } - - SAFE_FREE(*dst); - - *dst = malloc(copysize + 1); - - if (*dst == NULL) { - media_svc_error("malloc failed"); - return MS_MEDIA_ERR_INTERNAL; - } - - strncpy(*dst, src, copysize); - char *p = *dst; - p[copysize] = '\0'; - - return MS_MEDIA_ERR_NONE; -} - static int __media_svc_split_to_double(char *input, double *arr) { char tmp_arr[255] = {0, }; @@ -1402,16 +1379,11 @@ int _media_svc_extract_image_metadata(sqlite3 *handle, media_svc_content_info_s if (strlen(buf) == 0) { /*media_svc_debug("time is NULL"); */ } else { - ret = __media_svc_malloc_and_strncpy_with_size(&content_info->media_meta.datetaken, buf, MEDIA_SVC_DATATAKEN_SIZE); - if (ret != MS_MEDIA_ERR_NONE) { - media_svc_error("strcpy error"); - } else { - has_datetaken = TRUE; - /* This is same as recorded_date */ - ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.recorded_date, buf); - if (ret != MS_MEDIA_ERR_NONE) - media_svc_error("strcpy error"); - } + has_datetaken = TRUE; + content_info->media_meta.datetaken = g_strdup(buf); + + /* This is same as recorded_date */ + content_info->media_meta.recorded_date = g_strdup(buf); } } @@ -1421,16 +1393,11 @@ int _media_svc_extract_image_metadata(sqlite3 *handle, media_svc_content_info_s if (strlen(buf) == 0) { /*media_svc_debug("time is NULL"); */ } else { - ret = __media_svc_malloc_and_strncpy_with_size(&content_info->media_meta.datetaken, buf, MEDIA_SVC_DATATAKEN_SIZE); - if (ret != MS_MEDIA_ERR_NONE) { - media_svc_error("strcpy error"); - } else { - has_datetaken = TRUE; - /* This is same as recorded_date */ - ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.recorded_date, buf); - if (ret != MS_MEDIA_ERR_NONE) - media_svc_error("strcpy error"); - } + has_datetaken = TRUE; + content_info->media_meta.datetaken = g_strdup(buf); + + /* This is same as recorded_date */ + content_info->media_meta.recorded_date = g_strdup(buf); } } @@ -1826,13 +1793,7 @@ int _media_svc_extract_media_metadata(sqlite3 *handle, media_svc_content_info_s media_svc_error("strcpy error"); } else { /* This is same as datetaken */ -#if 0 - ret = __media_svc_malloc_and_strncpy(&content_info->media_meta.datetaken, content_info->media_meta.recorded_date); -#else - ret = __media_svc_malloc_and_strncpy_with_size(&content_info->media_meta.datetaken, content_info->media_meta.recorded_date, MEDIA_SVC_DATATAKEN_SIZE); -#endif - if (ret != MS_MEDIA_ERR_NONE) - media_svc_error("strcpy error"); + content_info->media_meta.datetaken = g_strdup(content_info->media_meta.recorded_date); content_info->timeline = __media_svc_get_timeline_from_str(content_info->media_meta.recorded_date); if (content_info->timeline == 0) diff --git a/src/include/common/media-svc-env.h b/src/include/common/media-svc-env.h index cce9cc3..0a1ef9b 100755 --- a/src/include/common/media-svc-env.h +++ b/src/include/common/media-svc-env.h @@ -130,7 +130,6 @@ extern "C" { #define MEDIA_SVC_METADATA_LEN_MAX 512 /**< Length of metadata*/ -#define MEDIA_SVC_DATATAKEN_SIZE 19 /**< Length of datataken */ #define MEDIA_SVC_PATHNAME_SIZE 4096 /**< Length of Path name. */ #define MEDIA_SVC_UUID_SIZE 36 /**< Length of UUID*/ #define MEDIA_SVC_QUERY_LEN_MAX 4096*2 /**< Max Query length*/