Improve image_util_transform_create() 62/236462/3
authorhj kim <backto.kim@samsung.com>
Wed, 17 Jun 2020 07:45:29 +0000 (16:45 +0900)
committerhj kim <backto.kim@samsung.com>
Thu, 18 Jun 2020 01:15:08 +0000 (01:15 +0000)
g_new0 and g_async_queue_new_full not return NULL.

Change-Id: I67459034e4693817776b5c3030a5c453399925af

src/image_util.c

index b6f6f8f0cb7b4ff496a44a816742447a693535e7..6b9fd7e49549ad11f28c63882a8dd5c2bfcc2e59 100644 (file)
@@ -197,8 +197,7 @@ int image_util_transform_create(transformation_h * handle)
 
        image_util_retvm_if(!handle, IMAGE_UTIL_ERROR_INVALID_PARAMETER, "Invalid Handle");
 
-       transformation_s *_handle = (transformation_s *) calloc(1, sizeof(transformation_s));
-       image_util_retvm_if((_handle == NULL), IMAGE_UTIL_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
+       transformation_s *_handle = g_new0(transformation_s, 1);
 
        /* private values init */
        _handle->color = MM_UTIL_COLOR_NUM;
@@ -216,10 +215,6 @@ int image_util_transform_create(transformation_h * handle)
 
        /* The queue is a communicator for thread */
        _handle->queue = g_async_queue_new_full(__destroy_async_queue);
-       if (!_handle->queue) {
-               image_util_error("g_async_queue_new failed");
-               goto Error;
-       }
 
        /* create thread */
        _handle->thread = g_thread_new("transform_thread", __transform_thread, (gpointer)_handle->queue);
@@ -227,15 +222,6 @@ int image_util_transform_create(transformation_h * handle)
        *handle = (transformation_h) _handle;
 
        return IMAGE_UTIL_ERROR_NONE;
-
-Error:
-       if (_handle->queue)
-               g_async_queue_unref(_handle->queue);
-       if (_handle->thread)
-               g_thread_unref(_handle->thread);
-       IMAGE_UTIL_SAFE_FREE(_handle);
-
-       return IMAGE_UTIL_ERROR_INVALID_OPERATION;
 }
 
 int image_util_transform_set_hardware_acceleration(transformation_h handle, bool mode)
@@ -487,7 +473,7 @@ int image_util_transform_destroy(transformation_h handle)
                _handle->queue = NULL;
        }
 
-       IMAGE_UTIL_SAFE_FREE(_handle);
+       IMAGE_UTIL_SAFE_G_FREE(_handle);
 
        image_util_fleave();