Remove buffer in gif structure 11/191611/2
authorjiyong.min <jiyong.min@samsung.com>
Fri, 19 Oct 2018 04:02:17 +0000 (13:02 +0900)
committerjiyong.min <jiyong.min@samsung.com>
Fri, 19 Oct 2018 04:28:58 +0000 (13:28 +0900)
Change-Id: I78160d70d2ac810c2b827bf918ba58801b6bd1d5

gif/CMakeLists.txt
gif/include/mm_util_gif_private.h
gif/mm_util_gif.c

index 59339b2..536c4ef 100755 (executable)
@@ -68,4 +68,4 @@ CONFIGURE_FILE(
 )
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PC_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
 
-ADD_SUBDIRECTORY(test)
+#ADD_SUBDIRECTORY(test)
index 1cf029b..273131b 100755 (executable)
@@ -32,7 +32,7 @@ extern "C" {
 typedef struct {
        size_t size;
        size_t mem_size;
-       void **mem;
+       void *mem;
 } gif_mem_s;
 
 typedef struct {
@@ -40,7 +40,6 @@ typedef struct {
        char *filename;
        void **enc_buffer;                        /**< Encoded output data attached to callback */
        size_t *enc_buffer_size;
-       unsigned char *buffer;
        gif_mem_s write_data_ptr;                 /**< Encoded output data attached to callback */
        gboolean is_started;
 } gif_file_s;
index c814368..0831997 100755 (executable)
@@ -277,12 +277,11 @@ static int __write_function(GifFileType *gft, const GifByteType *data, int size)
 
        mm_util_retvm_if(size <= 0, 0, "Failed to write memory due to size(%d).", size);
        mm_util_retvm_if(write_data_ptr == NULL, 0, "Failed to write memory due to invalid output data.");
-       mm_util_retvm_if(write_data_ptr->mem == NULL, 0, "Failed to write memory due to invalid output buffer.");
 
-       *(write_data_ptr->mem) = (void *)realloc(*(write_data_ptr->mem), (write_data_ptr->size + size));
-       mm_util_retvm_if(*(write_data_ptr->mem) == NULL, 0, "Failed to write memory due to allocation failure.");
+       write_data_ptr->mem = (void *)realloc(write_data_ptr->mem, (write_data_ptr->size + size));
+       mm_util_retvm_if(write_data_ptr->mem == NULL, 0, "Failed to write memory due to allocation failure.");
 
-       memcpy(*(write_data_ptr->mem) + write_data_ptr->size, data, size);
+       memcpy(write_data_ptr->mem + write_data_ptr->size, data, size);
        write_data_ptr->size += size;
 
        return size;
@@ -386,7 +385,7 @@ int _gif_encode_open_mem(gif_file_s *gif_file)
        mm_util_fenter();
        mm_util_retvm_if(gif_file == NULL, MM_UTIL_ERROR_INVALID_PARAMETER, "Invalid parameter");
 
-       gif_file->write_data_ptr.mem = (void**)&(gif_file->buffer);
+       gif_file->write_data_ptr.mem = NULL;
        gif_file->write_data_ptr.size = 0;
 
        if ((gif_file->GifFile = EGifOpen(&(gif_file->write_data_ptr), __write_function, NULL)) == NULL) {
@@ -695,9 +694,9 @@ int mm_util_gif_encode_save(mm_gif_file_h gif_file_h)
                ret = _gif_encode_move_to_file(gif_file->filename);
                mm_util_retvm_if(ret != MM_UTIL_ERROR_NONE, ret, "__move_tmp_to_origin failed");
        } else if (gif_file->write_data_ptr.mem != NULL) {
-               ret = _gif_encode_move_to_mem(gif_file->buffer, gif_file->write_data_ptr.size,
+               ret = _gif_encode_move_to_mem(gif_file->write_data_ptr.mem, gif_file->write_data_ptr.size,
                        gif_file->enc_buffer, gif_file->enc_buffer_size);
-               MMUTIL_SAFE_FREE(gif_file->buffer);
+               MMUTIL_SAFE_FREE(gif_file->write_data_ptr.mem);
                gif_file->write_data_ptr.size = 0;
                mm_util_retvm_if(ret != MM_UTIL_ERROR_NONE, ret, "_gif_encode_move_to_origin_mem failed");
        }
@@ -780,5 +779,5 @@ void mm_util_gif_encode_destroy(mm_gif_file_h gif_file_h)
        }
 
        MMUTIL_SAFE_G_FREE(gif_file->filename);
-       MMUTIL_SAFE_FREE(gif_file->buffer);
+       MMUTIL_SAFE_FREE(gif_file->write_data_ptr.mem);
 }