GIFTranslator: use ENTRY_COUNT define instead of 4096

This commit is contained in:
John Scipione 2014-03-01 15:58:35 -05:00
parent 5b53a45a94
commit 4ac43a1be4
2 changed files with 10 additions and 8 deletions

View File

@ -331,7 +331,7 @@ GIFLoad::ReadGIFImageHeader()
bool
GIFLoad::ReadGIFImageData()
{
unsigned char newEntry[4096];
unsigned char newEntry[ENTRY_COUNT];
unsigned char cs;
fInput->Read(&cs, 1);
@ -489,7 +489,7 @@ GIFLoad::ResetTable()
fMaxCode = (1 << fBits) - 1;
MemblockDeleteAll();
for (int x = 0; x < 4096; x++) {
for (int x = 0; x < ENTRY_COUNT; x++) {
fTable[x] = NULL;
if (x < (1 << fCodeSize)) {
fTable[x] = MemblockAllocate(1);
@ -553,8 +553,8 @@ GIFLoad::MemblockAllocate(int size)
Memblock* block = fHeadMemblock;
Memblock* last = NULL;
while (block != NULL) {
if (4096 - block->offset > size) {
uchar* value = block->data + block->offset;
if (ENTRY_COUNT - block->offset > size) {
unsigned char* value = block->data + block->offset;
block->offset += size;
return value;

View File

@ -26,9 +26,11 @@
#define GIF_INTERLACED 0x40
#define GIF_LOCALCOLORMAP 0x80
#define ENTRY_COUNT 4096
typedef struct Memblock {
unsigned char data[4096];
unsigned char data[ENTRY_COUNT];
int offset;
Memblock* next;
} Memblock;
@ -76,7 +78,7 @@ private:
int fWidth;
int fHeight;
unsigned char fOldCode[4096];
unsigned char fOldCode[ENTRY_COUNT];
unsigned int fOldCodeLength;
short fNewCode;
@ -88,8 +90,8 @@ private:
short fEndCode;
short fNextCode;
unsigned char* fTable[4096];
short fEntrySize[4096];
unsigned char* fTable[ENTRY_COUNT];
short fEntrySize[ENTRY_COUNT];
Memblock* fHeadMemblock;
int fBitCount;