From 03aea013f3c7f96889cff2f0b575003035317471 Mon Sep 17 00:00:00 2001 From: Jiyong Date: Mon, 5 Feb 2024 13:05:36 +0900 Subject: [PATCH] Add 'free_on_destroy' variables for memory release Change-Id: Ie3cfaa5639e9040afa91ca38fe1bec2435af2e7f --- common/include/mm_util_type.h | 2 +- common/mm_util_image.c | 18 +++++++++--------- packaging/libmm-utility.spec | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/common/include/mm_util_type.h b/common/include/mm_util_type.h index 3b997e8..714ff91 100755 --- a/common/include/mm_util_type.h +++ b/common/include/mm_util_type.h @@ -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; diff --git a/common/mm_util_image.c b/common/mm_util_image.c index ff3df6c..dba0736 100755 --- a/common/mm_util_image.c +++ b/common/mm_util_image.c @@ -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); } diff --git a/packaging/libmm-utility.spec b/packaging/libmm-utility.spec index 3c06ae3..acde0cb 100644 --- a/packaging/libmm-utility.spec +++ b/packaging/libmm-utility.spec @@ -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 -- 2.7.4