From: Haejeong Kim Date: Wed, 6 Sep 2017 04:46:41 +0000 (+0900) Subject: Change free to SAFE_FREE X-Git-Tag: submit/tizen/20170906.051057^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1a9960411c7e3241cfae6bfb1246ea059ed8c4cd;p=platform%2Fcore%2Fmultimedia%2Flibmm-utility.git Change free to SAFE_FREE Change-Id: I09f419176a7a3fed9fcb9ff35faee3f9104fb545 --- diff --git a/bmp/mm_util_bmp.c b/bmp/mm_util_bmp.c index cd9d9a8..9d7a628 100755 --- a/bmp/mm_util_bmp.c +++ b/bmp/mm_util_bmp.c @@ -76,7 +76,7 @@ static unsigned char *__load_file(const char *path, size_t * data_size) n = fread(buffer, 1, size, fd); if (n != size) { mm_util_error("file read failed"); - free(buffer); + BMP_SAFE_FREE(buffer); fclose(fd); return NULL; } @@ -121,7 +121,7 @@ size_t __bitmap_get_bpp(void *bitmap) void __bitmap_destroy(void *bitmap) { - free(bitmap); + BMP_SAFE_FREE(bitmap); } static int __read_bmp(mm_util_bmp_data *decoded, const char *filename, void *memory, unsigned long long src_size) @@ -184,7 +184,7 @@ static int __read_bmp(mm_util_bmp_data *decoded, const char *filename, void *mem cleanup: bmp_finalise(&bmp); if (filename) - free(data); + BMP_SAFE_FREE(data); return res; } diff --git a/gif/mm_util_gif.c b/gif/mm_util_gif.c index c119f30..a25c529 100755 --- a/gif/mm_util_gif.c +++ b/gif/mm_util_gif.c @@ -473,14 +473,14 @@ static int __write_gif(mm_util_gif_data *encoded) if ((OutputColorMap = GifMakeMapObject(ColorMapSize, NULL)) == NULL) { mm_util_error("could not map object"); RGB_FREE(red, green, blue); - free(OutputBuffer); + MMUTIL_SAFE_FREE(OutputBuffer); mm_util_encode_close_gif(encoded); return MM_UTIL_ERROR_INVALID_OPERATION; } if (GifQuantizeBuffer(encoded->frames[i]->width, encoded->frames[i]->height, &ColorMapSize, red, green, blue, OutputBuffer, OutputColorMap->Colors) == GIF_ERROR) { mm_util_error("could not quantize buffer"); RGB_FREE(red, green, blue); - free(OutputBuffer); + MMUTIL_SAFE_FREE(OutputBuffer); GifFreeMapObject(OutputColorMap); mm_util_encode_close_gif(encoded); return MM_UTIL_ERROR_INVALID_OPERATION; @@ -502,13 +502,13 @@ static int __write_gif(mm_util_gif_data *encoded) /* encode OutputBuffer to GifFile */ if (__save_buffer_to_gif(encoded->GifFile, OutputBuffer, OutputColorMap, encoded->frames[i]) != MM_UTIL_ERROR_NONE) { mm_util_error("save_buffer_to_gif is failed"); - free(OutputBuffer); + MMUTIL_SAFE_FREE(OutputBuffer); GifFreeMapObject(OutputColorMap); mm_util_encode_close_gif(encoded); return MM_UTIL_ERROR_INVALID_OPERATION; } - free(OutputBuffer); + MMUTIL_SAFE_FREE(OutputBuffer); GifFreeMapObject(OutputColorMap); encoded->current_count++; } @@ -600,10 +600,9 @@ int __gif_make_color_map(gif_image_s *gif_image) goto SUCCESS; FAIL: - if (gif_image->intermediate_image) { - free(gif_image->intermediate_image); - gif_image->intermediate_image = NULL; - } + if (gif_image->intermediate_image) + MMUTIL_SAFE_FREE(gif_image->intermediate_image); + gif_image->intermediate_image_size = 0; COLORMAP_FREE(gif_image->image_desc.ColorMap); SUCCESS: diff --git a/imgcv/mm_util_imgcv.c b/imgcv/mm_util_imgcv.c index de8581a..8a37702 100755 --- a/imgcv/mm_util_imgcv.c +++ b/imgcv/mm_util_imgcv.c @@ -230,8 +230,7 @@ int mm_util_cv_extract_representative_color(void *image_buffer, int width, int h int ret = _mm_util_imgcv_init(handle, width, height); if (ret != MM_UTIL_ERROR_NONE) { _mm_util_imgcv_uninit(handle); - free(handle); - handle = NULL; + MMUTIL_SAFE_FREE(handle); mm_util_error("#ERROR#: Fail to mm_util_imgcv_init: ret=%d", ret); @@ -241,8 +240,7 @@ int mm_util_cv_extract_representative_color(void *image_buffer, int width, int h ret = _mm_util_imgcv_set_buffer(handle, image_buffer); if (ret != MM_UTIL_ERROR_NONE) { _mm_util_imgcv_uninit(handle); - free(handle); - handle = NULL; + MMUTIL_SAFE_FREE(handle); mm_util_error("#ERROR#: Fail to mm_util_imgcv_set_buffer: ret=%d", ret); @@ -252,8 +250,7 @@ int mm_util_cv_extract_representative_color(void *image_buffer, int width, int h ret = _mm_util_imgcv_calculate_hist(handle, r_color, g_color, b_color); if (ret != MM_UTIL_ERROR_NONE) { _mm_util_imgcv_uninit(handle); - free(handle); - handle = NULL; + MMUTIL_SAFE_FREE(handle); mm_util_error("#ERROR#: Fail to mm_util_imgcv_calculate_hist: ret=%d", ret); @@ -262,8 +259,7 @@ int mm_util_cv_extract_representative_color(void *image_buffer, int width, int h _mm_util_imgcv_uninit(handle); - free(handle); - handle = NULL; + MMUTIL_SAFE_FREE(handle); mm_util_debug("Leave mm_util_cv_extract_representative_color");