Skip to content

Commit

Permalink
resolved the realloc problem
Browse files Browse the repository at this point in the history
  • Loading branch information
pkrumins committed Aug 6, 2010
1 parent 07e1b92 commit 9321221
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/gif_encoder.cpp
Expand Up @@ -127,14 +127,14 @@ int
gif_writer(GifFileType *gif_file, const GifByteType *data, int size)
{
GifImage *gif = (GifImage *)gif_file->UserData;
if (gif->mem_size < gif->size + size) {
GifByteType *new_ptr = (GifByteType *)realloc(gif->gif, gif->size + size + 1000*1024);
if (gif->size + size > gif->mem_size) {
GifByteType *new_ptr = (GifByteType *)realloc(gif->gif, gif->size + size + 10*1024);
if (!new_ptr) {
free(gif->gif);
throw "realloc in gif_writer failed";
}
gif->gif = new_ptr;
gif->mem_size += size + 1000*1024;
gif->mem_size = gif->size + size + 10*1024;
}
memcpy(gif->gif + gif->size, data, size);
gif->size += size;
Expand Down

0 comments on commit 9321221

Please sign in to comment.