From: hj kim Date: Thu, 9 Jul 2020 09:30:27 +0000 (+0900) Subject: Improve __mm_util_get_map() X-Git-Tag: submit/tizen/20200710.064028~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F05%2F238205%2F4;p=platform%2Fcore%2Fmultimedia%2Flibmm-utility.git Improve __mm_util_get_map() Modify to return const char * Change-Id: I1dd26c3904a88cb74fdaf73785386b67c61f7a63 --- diff --git a/magick/mm_util_magick.c b/magick/mm_util_magick.c index 455e1b1..a9f5b83 100644 --- a/magick/mm_util_magick.c +++ b/magick/mm_util_magick.c @@ -91,36 +91,28 @@ static void __mm_util_finalize(Image *image_1, Image *image_2, ExceptionInfo *ex DestroyMagick(); } -static int __mm_util_get_map(mm_util_color_format_e format, char **map) +static const char * __mm_util_get_map(mm_util_color_format_e format) { - mm_util_retvm_if(map == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid map"); switch (format) { case MM_UTIL_COLOR_RGB24: - *map = g_strdup("RGB"); - break; + return "RGB"; case MM_UTIL_COLOR_ARGB: - *map = g_strdup("ARGB"); - break; + return "ARGB"; case MM_UTIL_COLOR_BGRA: - *map = g_strdup("BGRA"); - break; + return "BGRA"; case MM_UTIL_COLOR_RGBA: - *map = g_strdup("RGBA"); - break; + return "RGBA"; default: mm_util_error("Not supported format. [%d]", format); - return MM_UTIL_ERROR_INVALID_PARAMETER; + return NULL; } - - return MM_UTIL_ERROR_NONE; } static Image * __mm_util_constitute_image(mm_util_image_h handle) { - int ret = MM_UTIL_ERROR_NONE; mm_image_info_s *_handle = (mm_image_info_s*)handle; - char *map = NULL; + const char *map = NULL; Image *_image = NULL; ExceptionInfo exception; @@ -128,8 +120,8 @@ static Image * __mm_util_constitute_image(mm_util_image_h handle) mm_util_retvm_if(!handle, NULL, "invalid handle"); - ret = __mm_util_get_map(_handle->color, &map); - mm_util_retvm_if(ret != MM_UTIL_ERROR_NONE, NULL, "fail to get map"); + map = __mm_util_get_map(_handle->color); + mm_util_retvm_if(!map, NULL, "fail to get map"); GetExceptionInfo(&exception); @@ -142,7 +134,6 @@ static Image * __mm_util_constitute_image(mm_util_image_h handle) } DestroyExceptionInfo(&exception); - g_free(map); mm_util_fleave(); @@ -361,14 +352,14 @@ static int __mm_util_dispatch_image(Image *image, mm_util_color_format_e format, void *pixels = NULL; unsigned int width = 0; unsigned int height = 0; - char *map = NULL; + const char *map = NULL; mm_util_fenter(); mm_util_retvm_if(!image, MM_UTIL_ERROR_INVALID_PARAMETER, "invalid image"); - ret = __mm_util_get_map(format, &map); - mm_util_retvm_if(ret != MM_UTIL_ERROR_NONE, ret, "fail to get map"); + map = __mm_util_get_map(format); + mm_util_retvm_if(!map, MM_UTIL_ERROR_INVALID_PARAMETER, "fail to get map"); GetExceptionInfo(&exception); @@ -404,7 +395,6 @@ static int __mm_util_dispatch_image(Image *image, mm_util_color_format_e format, ERROR: DestroyExceptionInfo(&exception); - g_free(map); mm_util_fleave();