From f8669393901bb32ec8710404d153e105ff3bb417 Mon Sep 17 00:00:00 2001 From: Jiyong Min Date: Fri, 20 Oct 2017 12:53:44 +0900 Subject: [PATCH] Remove unneccessary xxx_destroy_image_handle and replace initial value to NULL Change-Id: I3f66f7c3ccf4296d22202de39c7928bb4a46ab24 Signed-off-by: Jiyong Min --- packaging/capi-media-image-util.spec | 2 +- src/image_util.c | 2 +- src/image_util_decode.c | 31 +++++++--------------------- src/image_util_encode.c | 6 +++--- 4 files changed, 12 insertions(+), 29 deletions(-) diff --git a/packaging/capi-media-image-util.spec b/packaging/capi-media-image-util.spec index bda43e0..ff7973c 100755 --- a/packaging/capi-media-image-util.spec +++ b/packaging/capi-media-image-util.spec @@ -1,6 +1,6 @@ Name: capi-media-image-util Summary: A Image Utility library in Tizen Native API -Version: 0.1.29 +Version: 0.1.30 Release: 2 Group: Multimedia/API License: Apache-2.0 diff --git a/src/image_util.c b/src/image_util.c index 8f96c43..49a7b06 100755 --- a/src/image_util.c +++ b/src/image_util.c @@ -80,7 +80,7 @@ int image_util_transform_create(transformation_h * handle) _handle->colorspace = _NOT_SUPPORTED_COLORSPACE; _handle->_util_cb = NULL; - _handle->image_h = 0; + _handle->image_h = NULL; _handle->hardware_acceleration = false; _handle->set_convert = false; _handle->set_resize = false; diff --git a/src/image_util_decode.c b/src/image_util_decode.c index c9e8715..5ee3402 100755 --- a/src/image_util_decode.c +++ b/src/image_util_decode.c @@ -106,23 +106,12 @@ static int _image_util_decode_check_image_type(const unsigned char *image_buffer return IMAGE_UTIL_ERROR_NONE; } -static void _image_util_decode_destroy_image_handle(decode_encode_s * handle) -{ - image_util_retm_if((handle == NULL), "Invalid Handle"); - void *image_handle = (void *)(handle->image_h); - image_util_retm_if((image_handle == NULL), "Invalid image handle"); - - IMAGE_UTIL_SAFE_FREE(image_handle); -} - static int _image_util_decode_create_jpeg_handle(decode_encode_s * handle) { image_util_retvm_if((handle == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle"); /* It is needed to reuse decode handle for C#, so it shoud be reallocated */ - void *image_handle = (void *)(handle->image_h); - if (image_handle != NULL) - _image_util_decode_destroy_image_handle(handle); + IMAGE_UTIL_SAFE_FREE(handle->image_h); mm_util_jpeg_yuv_data *_handle = (mm_util_jpeg_yuv_data *) calloc(1, sizeof(mm_util_jpeg_yuv_data)); image_util_retvm_if((_handle == NULL), IMAGE_UTIL_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY"); @@ -139,9 +128,7 @@ static int _image_util_decode_create_png_handle(decode_encode_s * handle) image_util_retvm_if((handle == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle"); /* It is needed to reuse decode handle for C#, so it shoud be reallocated */ - void *image_handle = (void *)(handle->image_h); - if (image_handle != NULL) - _image_util_decode_destroy_image_handle(handle); + IMAGE_UTIL_SAFE_FREE(handle->image_h); mm_util_png_data *_handle = (mm_util_png_data *) calloc(1, sizeof(mm_util_png_data)); image_util_retvm_if((_handle == NULL), IMAGE_UTIL_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY"); @@ -158,9 +145,7 @@ static int _image_util_decode_create_gif_handle(decode_encode_s * handle) image_util_retvm_if((handle == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle"); /* It is needed to reuse decode handle for C#, so it shoud be reallocated */ - void *image_handle = (void *)(handle->image_h); - if (image_handle != NULL) - _image_util_decode_destroy_image_handle(handle); + IMAGE_UTIL_SAFE_FREE(handle->image_h); mm_util_gif_data *_handle = (mm_util_gif_data *) calloc(1, sizeof(mm_util_gif_data)); image_util_retvm_if((_handle == NULL), IMAGE_UTIL_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY"); @@ -175,9 +160,7 @@ static int _image_util_decode_create_bmp_handle(decode_encode_s * handle) image_util_retvm_if((handle == NULL), IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle"); /* It is needed to reuse decode handle for C#, so it shoud be reallocated */ - void *image_handle = (void *)(handle->image_h); - if (image_handle != NULL) - _image_util_decode_destroy_image_handle(handle); + IMAGE_UTIL_SAFE_FREE(handle->image_h); mm_util_bmp_data *_handle = (mm_util_bmp_data *) calloc(1, sizeof(mm_util_bmp_data)); image_util_retvm_if((_handle == NULL), IMAGE_UTIL_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY"); @@ -199,7 +182,7 @@ int image_util_decode_create(image_util_decode_h * handle) _handle->src_buffer = NULL; _handle->dst_buffer = NULL; _handle->path = NULL; - _handle->image_h = 0; + _handle->image_h = NULL; _handle->is_decode = TRUE; _handle->image_type = _NOT_SUPPORTED_IMAGE_TYPE; @@ -313,7 +296,7 @@ int image_util_decode_set_input_buffer(image_util_decode_h handle, const unsigne _handle->src_buffer = (void *)calloc(1, sizeof(void *)); if (_handle->src_buffer == NULL) { image_util_error("The memory of input buffer was not allocated"); - _image_util_decode_destroy_image_handle(_handle); + IMAGE_UTIL_SAFE_FREE(_handle->image_h); return IMAGE_UTIL_ERROR_OUT_OF_MEMORY; } @@ -614,7 +597,7 @@ int image_util_decode_destroy(image_util_decode_h handle) return IMAGE_UTIL_ERROR_INVALID_PARAMETER; } - _image_util_decode_destroy_image_handle(_handle); + IMAGE_UTIL_SAFE_FREE(_handle->image_h); /* g_thread_exit(handle->thread); */ if (_handle->thread) { diff --git a/src/image_util_encode.c b/src/image_util_encode.c index b0d287a..1b52abe 100755 --- a/src/image_util_encode.c +++ b/src/image_util_encode.c @@ -132,7 +132,7 @@ int image_util_encode_create(image_util_type_e image_type, image_util_encode_h * _handle->src_buffer = NULL; _handle->dst_buffer = NULL; _handle->path = NULL; - _handle->image_h = 0; + _handle->image_h = NULL; _handle->is_decode = FALSE; _handle->is_encoded = FALSE; _handle->current_buffer_count = 0; @@ -401,7 +401,7 @@ int image_util_encode_set_input_buffer(image_util_encode_h handle, const unsigne } err = mm_util_gif_image_set_image(frame, src_buffer); if (err != MM_UTIL_ERROR_NONE) { - image_util_error("mm_util_gif_image_set_delay_time is failed %d", err); + image_util_error("mm_util_gif_image_set_image is failed %d", err); return _image_error_capi(ERR_TYPE_ENCODE, err); } _handle->current_buffer_count++; @@ -425,7 +425,7 @@ int image_util_encode_set_output_path(image_util_encode_h handle, const char *pa image_util_error("Invalid Handle"); return IMAGE_UTIL_ERROR_INVALID_PARAMETER; } - image_util_retvm_if((path == NULL || strlen(path) == 0), IMAGE_UTIL_ERROR_NO_SUCH_FILE, "Invalid path"); + image_util_retvm_if(!IMAGE_UTIL_STRING_VALID(path), IMAGE_UTIL_ERROR_NO_SUCH_FILE, "Invalid path"); if (_handle->dst_buffer) _handle->dst_buffer = NULL; -- 2.34.1