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;
_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;
/* 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)
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)
if (!image)
return;
- if (_image->is_allocated)
+ if (_image->free_on_destroy)
g_free(_image->data);
g_free(_image);
}