Unify the type of the buffer size from 'unsigned int'/'unsigned long' to 'size_t' 71/171671/2
authorJiyong Min <jiyong.min@samsung.com>
Tue, 6 Mar 2018 09:44:00 +0000 (18:44 +0900)
committerJiyong Min <jiyong.min@samsung.com>
Tue, 6 Mar 2018 10:28:13 +0000 (19:28 +0900)
Change-Id: Ibbc37e0c3b5efde47c3d546fe10716c2b2292142
Signed-off-by: Jiyong Min <jiyong.min@samsung.com>
bmp/include/mm_util_bmp.h
bmp/mm_util_bmp.c
jpeg/include/mm_util_jpeg.h
jpeg/mm_util_jpeg.c
jpeg/test/mm_util_jpeg_testsuite.c
png/include/mm_util_png.h
png/mm_util_png.c

index 65e4220..5be6d36 100755 (executable)
@@ -38,7 +38,7 @@ extern "C" {
 typedef struct {
        unsigned long width;            /**< width */
        unsigned long height;           /**< height */
-       unsigned long long size;        /**< size */
+       size_t size;    /**< size */
        void *data;                     /**< data */
 } mm_util_bmp_data;
 
@@ -67,7 +67,7 @@ int mm_util_decode_from_bmp_file(const char *filename, mm_util_bmp_data * decode
  * @see                     mm_util_bmp_data
  * @since                   R1, 1.0
  */
-int mm_util_decode_from_bmp_memory(void *memory, unsigned long long src_size, mm_util_bmp_data * decoded);
+int mm_util_decode_from_bmp_memory(void *memory, const size_t src_size, mm_util_bmp_data * decoded);
 
 /**
  * This function encodes raw data to bmp file
index 9254813..b0e1f90 100755 (executable)
@@ -114,7 +114,7 @@ void __bitmap_destroy(void *bitmap)
        MMUTIL_SAFE_FREE(bitmap);
 }
 
-static int __read_bmp(mm_util_bmp_data *decoded, const char *filename, void *memory, unsigned long long src_size)
+static int __read_bmp(mm_util_bmp_data *decoded, const char *filename, void *memory, size_t src_size)
 {
        bmp_bitmap_callback_vt bitmap_callbacks = {
                __bitmap_create,
@@ -189,7 +189,7 @@ int mm_util_decode_from_bmp_file(const char *filename, mm_util_bmp_data *decoded
        return ret;
 }
 
-int mm_util_decode_from_bmp_memory(void *memory, unsigned long long src_size, mm_util_bmp_data *decoded)
+int mm_util_decode_from_bmp_memory(void *memory, const size_t src_size, mm_util_bmp_data *decoded)
 {
        int ret;
 
index 659d6ab..168fe49 100755 (executable)
@@ -53,7 +53,7 @@ typedef struct {
        mm_util_color_format_e format;     /**< pixel format*/
        int width;                          /**< width */
        int height;                         /**< heigt */
-       unsigned int size;                           /**< size */
+       size_t size;                           /**< size */
        void *data;                         /**< data */ //    int decode_yuv_subsample;                    /**< decode_yuv_subsample */
 } mm_util_jpeg_yuv_data;
 
@@ -84,7 +84,7 @@ int mm_util_jpeg_encode_to_file(mm_util_jpeg_yuv_data *decoded, int quality, con
  * @see         mm_util_color_format_e
  * @since       R1, 1.0
  */
-int mm_util_jpeg_encode_to_memory(mm_util_jpeg_yuv_data *decoded, int quality, void **mem, unsigned int *size);
+int mm_util_jpeg_encode_to_memory(mm_util_jpeg_yuv_data *decoded, int quality, void **mem, size_t *size);
 
 /**
  * This function extracts yuv data from jpeg file with downscale decode option
@@ -113,7 +113,7 @@ int mm_util_decode_from_jpeg_file_with_downscale(const char *filename, mm_util_c
  * @see         mm_util_jpeg_yuv_data, mm_util_color_format_e
  * @since       R1, 1.0
  */
-int mm_util_decode_from_jpeg_memory_with_downscale(void *src, unsigned int size, mm_util_color_format_e fmt, mm_util_jpeg_decode_downscale downscale, mm_util_jpeg_yuv_data *decoded);
+int mm_util_decode_from_jpeg_memory_with_downscale(void *src, const size_t size, mm_util_color_format_e fmt, mm_util_jpeg_decode_downscale downscale, mm_util_jpeg_yuv_data *decoded);
 
 
 #ifdef __cplusplus
index df6f717..3b6df45 100755 (executable)
@@ -400,7 +400,7 @@ typedef enum {
        MM_UTIL_JPEG_MEM,
 } mm_util_jpeg_cont_format_e;
 
-static int __mm_image_encode_with_libjpeg(mm_util_jpeg_cont_format_e control_format, FILE *fp, void **mem, unsigned int *csize, void *rawdata, int width, int height, mm_util_color_format_e color_format, int quality)
+static int __mm_image_encode_with_libjpeg(mm_util_jpeg_cont_format_e control_format, FILE *fp, void **mem, size_t *csize, void *rawdata, int width, int height, mm_util_color_format_e color_format, int quality)
 {
        int iErrorCode = MM_UTIL_ERROR_NONE;
 
@@ -589,12 +589,12 @@ static int __mm_image_encode_with_libjpeg(mm_util_jpeg_cont_format_e control_for
        }
 
        if (control_format == MM_UTIL_JPEG_MEM)
-               *csize = (unsigned int)size;
+               *csize = (size_t)size;
 
        return iErrorCode;
 }
 
-static int __mm_image_decode_with_libjpeg(mm_util_jpeg_cont_format_e control_format, mm_util_jpeg_yuv_data *decoded_data, FILE *fp, void *src, unsigned int size, mm_util_color_format_e color_format, mm_util_jpeg_decode_downscale downscale)
+static int __mm_image_decode_with_libjpeg(mm_util_jpeg_cont_format_e control_format, mm_util_jpeg_yuv_data *decoded_data, FILE *fp, void *src, size_t size, mm_util_color_format_e color_format, mm_util_jpeg_decode_downscale downscale)
 {
        int iErrorCode = MM_UTIL_ERROR_NONE;
        struct jpeg_decompress_struct dinfo;
@@ -635,7 +635,7 @@ static int __mm_image_decode_with_libjpeg(mm_util_jpeg_cont_format_e control_for
                jpeg_stdio_src(&dinfo, fp);
                mm_util_debug("jpeg_stdio_src");
        } else {
-               jpeg_mem_src(&dinfo, src, size);
+               jpeg_mem_src(&dinfo, src, (unsigned long)size);
                mm_util_debug("jpeg_mem_src");
        }
 
@@ -833,7 +833,7 @@ int mm_util_jpeg_encode_to_file(mm_util_jpeg_yuv_data *decoded, int quality, con
        return ret;
 }
 
-int mm_util_jpeg_encode_to_memory(mm_util_jpeg_yuv_data *decoded, int quality, void **mem, unsigned int *size)
+int mm_util_jpeg_encode_to_memory(mm_util_jpeg_yuv_data *decoded, int quality, void **mem, size_t *size)
 {
        int ret = MM_UTIL_ERROR_NONE;
 
@@ -934,7 +934,7 @@ int mm_util_decode_from_jpeg_file_with_downscale(const char *filename, mm_util_c
                                MMUTIL_SAFE_FREE(decoded->data);
 
                                decoded->data = dst;
-                               decoded->size = (unsigned int)res_buffer_size;
+                               decoded->size = res_buffer_size;
                        }
                } else {
                        ret = __mm_image_decode_with_libjpeg(MM_UTIL_JPEG_FILE, decoded, fp, NULL, 0, fmt, downscale);
@@ -963,7 +963,7 @@ int mm_util_decode_from_jpeg_file_with_downscale(const char *filename, mm_util_c
        return ret;
 }
 
-int mm_util_decode_from_jpeg_memory_with_downscale(void *src, unsigned int size, mm_util_color_format_e fmt, mm_util_jpeg_decode_downscale downscale, mm_util_jpeg_yuv_data *decoded)
+int mm_util_decode_from_jpeg_memory_with_downscale(void *src, const size_t size, mm_util_color_format_e fmt, mm_util_jpeg_decode_downscale downscale, mm_util_jpeg_yuv_data *decoded)
 {
        int ret = MM_UTIL_ERROR_NONE;
 
@@ -997,7 +997,7 @@ int mm_util_decode_from_jpeg_memory_with_downscale(void *src, unsigned int size,
                        MMUTIL_SAFE_FREE(decoded->data);
 
                        decoded->data = dst;
-                       decoded->size = (unsigned int)res_buffer_size;
+                       decoded->size = res_buffer_size;
                }
        } else {
                ret = __mm_image_decode_with_libjpeg(MM_UTIL_JPEG_MEM, decoded, NULL, src, size, fmt, downscale);
index a1cc89e..f8ffded 100755 (executable)
@@ -243,7 +243,7 @@ gboolean _test_decode(const jpeg_test_mode_e mode)
                        fprintf(stderr, "\t[JPEG_testsuite] mm_util_decode_from_jpeg_file_with_downscale failed %d\n", ret);
                        return FALSE;
                }
-               if (FALSE == _write_file(DECODE_FILE_PATH, g_decoded_data.data, (size_t)g_decoded_data.size)) {
+               if (FALSE == _write_file(DECODE_FILE_PATH, g_decoded_data.data, g_decoded_data.size)) {
                        fprintf(stderr, "\t[JPEG_testsuite] writing decoded data failed : %s\n", DECODE_FILE_PATH);
                        return FALSE;
                }
@@ -253,12 +253,12 @@ gboolean _test_decode(const jpeg_test_mode_e mode)
                        return FALSE;
                }
 
-               ret = mm_util_decode_from_jpeg_memory_with_downscale(g_readed_data, (unsigned int)g_readed_size, g_color, g_downscale, &g_decoded_data);
+               ret = mm_util_decode_from_jpeg_memory_with_downscale(g_readed_data, g_readed_size, g_color, g_downscale, &g_decoded_data);
                if (ret != MM_UTIL_ERROR_NONE) {
                        fprintf(stderr, "\t[JPEG_testsuite] mm_util_decode_from_jpeg_memory_with_downscale failed %d\n", ret);
                        return FALSE;
                }
-               if (FALSE == _write_file(DECODE_MEM_PATH, g_decoded_data.data, (size_t)g_decoded_data.size)) {
+               if (FALSE == _write_file(DECODE_MEM_PATH, g_decoded_data.data, g_decoded_data.size)) {
                        fprintf(stderr, "\t[JPEG_testsuite] writing decoded data failed : %s\n", DECODE_MEM_PATH);
                        return FALSE;
                }
@@ -272,16 +272,15 @@ gboolean _test_encode(const jpeg_test_mode_e mode)
        int ret = 0;
        /* for encoding jpeg to memory */
        void *encoded_data = NULL;
-       unsigned int encoded_size = 0;
+       size_t encoded_size = 0;
 
        if ((mode != TEST_ENCODE_FILE) && (mode != TEST_ENCODE_MEMORY))
                return TRUE;
 
-       if (FALSE == _read_file(g_path, &g_decoded_data.data, &g_readed_size)) {
+       if (FALSE == _read_file(g_path, &g_decoded_data.data, &g_decoded_data.size)) {
                fprintf(stderr, "\t[JPEG_testsuite] reading file error\n");
                return FALSE;
        }
-       g_decoded_data.size = (unsigned int)g_readed_size;
        g_decoded_data.format = (mm_util_color_format_e)g_color;
 
        /* test encoding jpeg */
@@ -298,7 +297,7 @@ gboolean _test_encode(const jpeg_test_mode_e mode)
                        SAFE_FREE(encoded_data);
                        return FALSE;
                }
-               if (FALSE == _write_file(ENCODE_MEM_PATH, encoded_data, (size_t)encoded_size)) {
+               if (FALSE == _write_file(ENCODE_MEM_PATH, encoded_data, encoded_size)) {
                        fprintf(stderr, "\t[JPEG_testsuite] writing decoded data failed : %s\n", ENCODE_MEM_PATH);
                        SAFE_FREE(encoded_data);
                        return FALSE;
index e405f07..278b8f4 100755 (executable)
@@ -82,7 +82,7 @@ int mm_util_decode_from_png_file(const char *fpath, mm_util_png_data * decoded);
  * @see                     mm_util_png_data, mm_util_init_decode_png
  * @since                   R1, 1.0
  */
-int mm_util_decode_from_png_memory(void *memory, unsigned long long src_size, mm_util_png_data * decoded);
+int mm_util_decode_from_png_memory(void *memory, const size_t src_size, mm_util_png_data * decoded);
 
 /**
  * This function extracts raw data to png file
index 6cc7d3c..809cbf1 100755 (executable)
@@ -218,7 +218,7 @@ int mm_util_decode_from_png_file(const char *fpath, mm_util_png_data *decoded)
        return ret;
 }
 
-int mm_util_decode_from_png_memory(void *memory, unsigned long long src_size, mm_util_png_data *decoded)
+int mm_util_decode_from_png_memory(void *memory, const size_t src_size, mm_util_png_data *decoded)
 {
        int ret = MM_UTIL_ERROR_NONE;