Skip to content

Instantly share code, notes, and snippets.

@scottjg
Last active August 29, 2015 14:14
Show Gist options
  • Save scottjg/07bc2ebf55f18a4e72fe to your computer and use it in GitHub Desktop.
Save scottjg/07bc2ebf55f18a4e72fe to your computer and use it in GitHub Desktop.
patch for imlib2 1.4.6 to work with giflib5
diff -ru imlib2-1.4.6.orig/src/modules/loaders/loader_gif.c imlib2-1.4.6/src/modules/loaders/loader_gif.c
--- imlib2-1.4.6.orig/src/modules/loaders/loader_gif.c 2015-01-30 18:32:56.000000000 -0800
+++ imlib2-1.4.6/src/modules/loaders/loader_gif.c 2015-01-30 18:35:59.000000000 -0800
@@ -36,7 +36,11 @@
#endif
if (fd < 0)
return 0;
+#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5
+ gif = DGifOpenFileHandle(fd, NULL);
+#else
gif = DGifOpenFileHandle(fd);
+#endif
if (!gif)
{
close(fd);
@@ -60,13 +64,21 @@
h = gif->Image.Height;
if (!IMAGE_DIMENSIONS_OK(w, h))
{
+#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5 && GIFLIB_MINOR >= 1
+ DGifCloseFile(gif, NULL);
+#else
DGifCloseFile(gif);
+#endif
return 0;
}
rows = malloc(h * sizeof(GifRowType *));
if (!rows)
{
+#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5 && GIFLIB_MINOR >= 1
+ DGifCloseFile(gif, NULL);
+#else
DGifCloseFile(gif);
+#endif
return 0;
}
for (i = 0; i < h; i++)
@@ -78,7 +90,11 @@
rows[i] = malloc(w * sizeof(GifPixelType));
if (!rows[i])
{
+#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5 && GIFLIB_MINOR >= 1
+ DGifCloseFile(gif, NULL);
+#else
DGifCloseFile(gif);
+#endif
for (i = 0; i < h; i++)
{
if (rows[i])
@@ -150,7 +166,11 @@
im->data = (DATA32 *) malloc(sizeof(DATA32) * w * h);
if (!im->data)
{
+#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5 && GIFLIB_MINOR >= 1
+ DGifCloseFile(gif, NULL);
+#else
DGifCloseFile(gif);
+#endif
free(rows);
return 0;
}
@@ -181,7 +201,11 @@
last_per = (int)per;
if (!(progress(im, (int)per, 0, last_y, w, i)))
{
+#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5 && GIFLIB_MINOR >= 1
+ DGifCloseFile(gif, NULL);
+#else
DGifCloseFile(gif);
+#endif
for (i = 0; i < h; i++)
{
free(rows[i]);
@@ -198,7 +222,11 @@
{
progress(im, 100, 0, last_y, w, h);
}
+#if defined(GIFLIB_MAJOR) && GIFLIB_MAJOR >= 5 && GIFLIB_MINOR >= 1
+ DGifCloseFile(gif, NULL);
+#else
DGifCloseFile(gif);
+#endif
for (i = 0; i < h; i++)
{
free(rows[i]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment