From 8e7a5e50149d4a4dbc1611147368448d8623b2cd Mon Sep 17 00:00:00 2001 From: David Capello Date: Wed, 27 Sep 2017 08:42:05 -0300 Subject: [PATCH] Fix gif encoding on x64 compiled with VS2017 bool is 1 byte on C++, not 4 bytes (int), so we cannot just "typedef int bool" and assume that structs with bools will have the same size on C++ than on C. --- third_party/giflib/lib/dgif_lib.c | 2 +- third_party/giflib/lib/egif_lib.c | 6 +++--- third_party/giflib/lib/gif_lib.h | 15 ++++++++------- third_party/giflib/lib/gif_lib_private.h | 2 +- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/third_party/giflib/lib/dgif_lib.c b/third_party/giflib/lib/dgif_lib.c index e2eb8271f..7639dbb54 100644 --- a/third_party/giflib/lib/dgif_lib.c +++ b/third_party/giflib/lib/dgif_lib.c @@ -236,7 +236,7 @@ int DGifGetScreenDesc(GifFileType *GifFile) { int BitsPerPixel; - bool SortFlag; + GifBool SortFlag; GifByteType Buf[3]; GifFilePrivateType *Private = (GifFilePrivateType *)GifFile->Private; diff --git a/third_party/giflib/lib/egif_lib.c b/third_party/giflib/lib/egif_lib.c index bf77cc1e5..6b6fa6598 100644 --- a/third_party/giflib/lib/egif_lib.c +++ b/third_party/giflib/lib/egif_lib.c @@ -57,7 +57,7 @@ static int EGifBufferedOutput(GifFileType * GifFile, GifByteType * Buf, info record. The Error member is cleared if successful. ******************************************************************************/ GifFileType * -EGifOpenFileName(const char *FileName, const bool TestExistence, int *Error) +EGifOpenFileName(const char *FileName, const GifBool TestExistence, int *Error) { int FileHandle; @@ -237,7 +237,7 @@ EGifGetGifVersion(GifFileType *GifFile) is 1 (numerically the same as bool true). That way we'll even preserve object-file compatibility! ******************************************************************************/ -void EGifSetGifVersion(GifFileType *GifFile, const bool gif89) +void EGifSetGifVersion(GifFileType *GifFile, const GifBool gif89) { GifFilePrivateType *Private = (GifFilePrivateType *) GifFile->Private; @@ -360,7 +360,7 @@ EGifPutImageDesc(GifFileType *GifFile, const int Top, const int Width, const int Height, - const bool Interlace, + const GifBool Interlace, const ColorMapObject *ColorMap) { GifByteType Buf[3]; diff --git a/third_party/giflib/lib/gif_lib.h b/third_party/giflib/lib/gif_lib.h index ad3f8f851..b202485ca 100644 --- a/third_party/giflib/lib/gif_lib.h +++ b/third_party/giflib/lib/gif_lib.h @@ -22,11 +22,12 @@ extern "C" { #ifdef HAVE_STDBOOL_H #include #elif !defined __cplusplus - typedef int bool; #define false 0 #define true 1 #endif +typedef int GifBool; + #define GIF_STAMP "GIFVER" /* First chars in file - GIF stamp. */ #define GIF_STAMP_LEN sizeof(GIF_STAMP) - 1 #define GIF_VERSION_POS 3 /* Version first character in stamp. */ @@ -46,13 +47,13 @@ typedef struct GifColorType { typedef struct ColorMapObject { int ColorCount; int BitsPerPixel; - bool SortFlag; + GifBool SortFlag; GifColorType *Colors; /* on malloc(3) heap */ } ColorMapObject; typedef struct GifImageDesc { GifWord Left, Top, Width, Height; /* Current image dimensions. */ - bool Interlace; /* Sequential/Interlaced lines. */ + GifBool Interlace; /* Sequential/Interlaced lines. */ ColorMapObject *ColorMap; /* The local color map */ } GifImageDesc; @@ -118,7 +119,7 @@ typedef struct GraphicsControlBlock { #define DISPOSE_DO_NOT 1 /* Leave image in place */ #define DISPOSE_BACKGROUND 2 /* Set area too background color */ #define DISPOSE_PREVIOUS 3 /* Restore to previous content */ - bool UserInputFlag; /* User confirmation required before disposal */ + GifBool UserInputFlag; /* User confirmation required before disposal */ int DelayTime; /* pre-display delay in 0.01sec units */ int TransparentColor; /* Palette index for transparency, -1 if none */ #define NO_TRANSPARENT_COLOR -1 @@ -130,7 +131,7 @@ typedef struct GraphicsControlBlock { /* Main entry points */ GifFileType *EGifOpenFileName(const char *GifFileName, - const bool GifTestExistence, int *Error); + const GifBool GifTestExistence, int *Error); GifFileType *EGifOpenFileHandle(const int GifFileHandle, int *Error); GifFileType *EGifOpen(void *userPtr, OutputFunc writeFunc, int *Error); int EGifSpew(GifFileType * GifFile); @@ -158,9 +159,9 @@ int EGifPutScreenDesc(GifFileType *GifFile, int EGifPutImageDesc(GifFileType *GifFile, const int GifLeft, const int GifTop, const int GifWidth, const int GifHeight, - const bool GifInterlace, + const GifBool GifInterlace, const ColorMapObject *GifColorMap); -void EGifSetGifVersion(GifFileType *GifFile, const bool gif89); +void EGifSetGifVersion(GifFileType *GifFile, const GifBool gif89); int EGifPutLine(GifFileType *GifFile, GifPixelType *GifLine, int GifLineLen); int EGifPutPixel(GifFileType *GifFile, const GifPixelType GifPixel); diff --git a/third_party/giflib/lib/gif_lib_private.h b/third_party/giflib/lib/gif_lib_private.h index adaf5571e..1d4ae4b1b 100644 --- a/third_party/giflib/lib/gif_lib_private.h +++ b/third_party/giflib/lib/gif_lib_private.h @@ -51,7 +51,7 @@ typedef struct GifFilePrivateType { GifByteType Suffix[LZ_MAX_CODE + 1]; /* So we can trace the codes. */ GifPrefixType Prefix[LZ_MAX_CODE + 1]; GifHashTableType *HashTable; - bool gif89; + GifBool gif89; } GifFilePrivateType; #endif /* _GIF_LIB_PRIVATE_H */