Improve __metadata_editor_get_picture_type() API 09/232109/5
authorhj kim <backto.kim@samsung.com>
Tue, 28 Apr 2020 08:50:25 +0000 (17:50 +0900)
committerhj kim <backto.kim@samsung.com>
Wed, 6 May 2020 07:26:58 +0000 (07:26 +0000)
Change-Id: Ib3fb371c5fd914ca94051f8151bcf4ec035bdff3

src/metadata_editor.cpp

index c2ffd52..7f6000a 100755 (executable)
@@ -696,7 +696,7 @@ int __metadata_editor_get_file_type(const char *path) {
        return METADATA_EDITOR_FORMAT_NOTYPE;
 }
 
-int __metadata_editor_get_picture_type(const char *path, char **type) {
+static int __metadata_editor_get_picture_type(const char *path, char **type) {
        int ret = 0;
        char mimetype[255] = {0, };
        const char *type_jpeg = "image/jpeg";
@@ -712,10 +712,10 @@ int __metadata_editor_get_picture_type(const char *path, char **type) {
                metadata_editor_retvm_if(ret < 0, METADATA_EDITOR_ERROR_OPERATION_FAILED, "__metadata_editor_get_file_ext failed");
 
                if (strcasecmp(ext, "JPG") == 0 || strcasecmp(ext, "JPEG") == 0) {
-                       *type = strndup(type_jpeg, strlen(type_jpeg));
+                       *type = g_strndup(type_jpeg, strlen(type_jpeg));
                        return METADATA_EDITOR_ERROR_NONE;
                } else if (strcasecmp(ext, "PNG") == 0) {
-                       *type = strndup(type_png, strlen(type_png));
+                       *type = g_strndup(type_png, strlen(type_png));
                        return METADATA_EDITOR_ERROR_NONE;
                } else {
                        return METADATA_EDITOR_ERROR_NOT_SUPPORTED;
@@ -726,10 +726,10 @@ int __metadata_editor_get_picture_type(const char *path, char **type) {
 
        /* categorize from mimetype */
        if (strstr(mimetype, "jpeg") != NULL) {
-               *type = strndup(mimetype, strlen(mimetype));
+               *type = g_strndup(mimetype, strlen(mimetype));
                return METADATA_EDITOR_ERROR_NONE;
        } else if (strstr(mimetype, "png") != NULL) {
-               *type = strndup(mimetype, strlen(mimetype));
+               *type = g_strndup(mimetype, strlen(mimetype));
                return METADATA_EDITOR_ERROR_NONE;
        }
 
@@ -1729,7 +1729,7 @@ extern "C" int metadata_editor_append_picture(metadata_editor_h metadata, const
        }
 
        META_SAFE_FREE(picture);
-       META_SAFE_FREE(type);
+       g_free(type);
 
        return ret;
 }