Remove __media_svc_malloc_and_strncpy_with_size() 79/140479/1
authorMinje Ahn <minje.ahn@samsung.com>
Tue, 25 Jul 2017 06:29:05 +0000 (15:29 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Tue, 25 Jul 2017 06:29:05 +0000 (15:29 +0900)
Use g_strdup instead of __media_svc_malloc_and_strncpy_with_size

Change-Id: I34df062c9b2c4b933a792ff78c34857e0f0dcb4f
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
src/common/media-svc-util.c
src/include/common/media-svc-env.h

index 2aaf6b5..58574a6 100755 (executable)
@@ -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)
index cce9cc3..0a1ef9b 100755 (executable)
@@ -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*/