Add 'free_on_destroy' variables for memory release 56/305556/4 accepted/tizen/unified/20240206.094542 accepted/tizen/unified/x/20240206.211047
authorJiyong <jiyong.min@samsung.com>
Mon, 5 Feb 2024 04:05:36 +0000 (13:05 +0900)
committerJiyong <jiyong.min@samsung.com>
Mon, 5 Feb 2024 09:33:32 +0000 (18:33 +0900)
Change-Id: Ie3cfaa5639e9040afa91ca38fe1bec2435af2e7f

common/include/mm_util_type.h
common/mm_util_image.c
packaging/libmm-utility.spec

index 3b997e8..714ff91 100755 (executable)
@@ -112,7 +112,7 @@ typedef struct {
        unsigned int width;
        unsigned int height;
        mm_util_color_format_e color;
-       bool is_allocated;
+       bool free_on_destroy;
        void *data;
        size_t size;
        unsigned int delay_time;
index ff3df6c..dba0736 100755 (executable)
@@ -37,14 +37,14 @@ void mm_image_debug_image(mm_util_image_h image, const char *message)
 
        mm_util_retm_if(image == NULL, "Invalid image");
 
-       mm_util_sec_debug("[%s] w [%u], h [%u], color [%u], data [%p], size [%zu], is_allocated [%d]",
+       mm_util_sec_debug("[%s] w [%u], h [%u], color [%u], data [%p], size [%zu], free_on_destroy [%d]",
                message ? message : "none", _image->width, _image->height, _image->color,
-               _image->data, _image->size, _image->is_allocated);
+               _image->data, _image->size, _image->free_on_destroy);
 }
 
 static int __create_new_image(unsigned int width, unsigned int height,
                mm_util_color_format_e color, const unsigned char *data, size_t size,
-               bool deep_copy, mm_util_image_h *image)
+               bool deep_copy, bool free_on_destroy, mm_util_image_h *image)
 {
        mm_image_info_s *_image = NULL;
 
@@ -67,7 +67,7 @@ static int __create_new_image(unsigned int width, unsigned int height,
        _image->width = width;
        _image->height = height;
        _image->color = color;
-       _image->is_allocated = deep_copy;
+       _image->free_on_destroy = free_on_destroy;
 
        *image = (mm_util_image_h)_image;
 
@@ -83,16 +83,16 @@ int mm_image_create_image(unsigned int width, unsigned int height,
        /* Just TEMP_DATA_SIZE has been used internally.
         * It will be removed after removing deprecated CAPIs. */
        if (size == TEMP_DATA_SIZE)
-               return __create_new_image(width, height, color, data, size, false, image);
+               return __create_new_image(width, height, color, data, size, false, false, image);
 
-       return __create_new_image(width, height, color, data, size, true, image);
+       return __create_new_image(width, height, color, data, size, true, true, image);
 }
 
 int mm_image_create_image2(unsigned int width, unsigned int height,
                mm_util_color_format_e color, const unsigned char *data, size_t size,
                mm_util_image_h *image)
 {
-       return __create_new_image(width, height, color, data, size, false, image);
+       return __create_new_image(width, height, color, data, size, false, true, image);
 }
 
 int mm_image_clone_image(mm_util_image_h src, mm_util_image_h *dst)
@@ -102,7 +102,7 @@ int mm_image_clone_image(mm_util_image_h src, mm_util_image_h *dst)
        mm_util_retvm_if(!src, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid src");
        mm_util_retvm_if(!dst, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid dst");
 
-       return __create_new_image(_src->width, _src->height, _src->color, _src->data, _src->size, _src->is_allocated, dst);
+       return __create_new_image(_src->width, _src->height, _src->color, _src->data, _src->size, true, true, dst);
 }
 
 int mm_image_set_delay_time(mm_util_image_h image, unsigned int delay_time)
@@ -163,7 +163,7 @@ void mm_image_destroy_image(mm_util_image_h image)
        if (!image)
                return;
 
-       if (_image->is_allocated)
+       if (_image->free_on_destroy)
                g_free(_image->data);
        g_free(_image);
 }
index 3c06ae3..acde0cb 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-utility
 Summary:    Multimedia Framework Utility Library
-Version:    0.4.15
+Version:    0.4.16
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0