Skip to content

Commit

Permalink
Merge pull request #5 from aczid/png
Browse files Browse the repository at this point in the history
Cleaned up use of pointers in PNG library
  • Loading branch information
annejan authored Jun 21, 2017
2 parents 1a6ef71 + fbb3231 commit ca3088f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions src/gdisp/gdisp_image_png.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ static bool_t PNG_zCopyInput(PNG_decode *d, unsigned length) {
WRAP_ZBUF(d->z.bufend);
if (d->z.bufend == d->z.bufpos) { // Buffer full?
d->z.flags = (d->z.flags & ~PNG_ZFLG_RESUME_MASK) | PNG_ZFLG_RESUME_COPY;
((unsigned *)d->z.tmp)[0] = length;
(d->z.tmp)[0] = length;
return TRUE;
}
}
Expand Down Expand Up @@ -570,8 +570,8 @@ static bool_t PNG_zInflateBlock(PNG_decode *d) {
WRAP_ZBUF(offset);
if (d->z.bufend == d->z.bufpos) { // Buffer full?
d->z.flags = (d->z.flags & ~PNG_ZFLG_RESUME_MASK) | PNG_ZFLG_RESUME_OFFSET;
((unsigned *)d->z.tmp)[0] = length;
((unsigned *)d->z.tmp)[1] = offset;
(d->z.tmp)[0] = length;
(d->z.tmp)[1] = offset;
return TRUE;
}
}
Expand Down Expand Up @@ -630,8 +630,8 @@ static bool_t PNG_zResumeOffset(PNG_decode *d, unsigned length, unsigned offset)
WRAP_ZBUF(offset);
if (d->z.bufend == d->z.bufpos) { // Buffer full?
d->z.flags = (d->z.flags & ~PNG_ZFLG_RESUME_MASK) | PNG_ZFLG_RESUME_OFFSET;
((unsigned *)d->z.tmp)[0] = length;
((unsigned *)d->z.tmp)[1] = offset;
(d->z.tmp)[0] = length;
(d->z.tmp)[1] = offset;
return TRUE;
}
}
Expand All @@ -653,15 +653,15 @@ static uint8_t PNG_zGetByte(PNG_decode *d) {
return 0xFF;
break;
case PNG_ZFLG_RESUME_COPY: // Resume uncompressed block copy for length bytes
if (!PNG_zCopyInput(d, ((unsigned *)d->z.tmp)[0]))
if (!PNG_zCopyInput(d, (d->z.tmp)[0]))
return 0xFF;
break;
case PNG_ZFLG_RESUME_INFLATE: // Resume compressed block
if (!PNG_zInflateBlock(d))
return 0xFF;
break;
case PNG_ZFLG_RESUME_OFFSET: // Resume compressed block using offset copy for length bytes
if (!PNG_zResumeOffset(d, ((unsigned *)d->z.tmp)[0], ((unsigned *)d->z.tmp)[1]))
if (!PNG_zResumeOffset(d, (d->z.tmp)[0], (d->z.tmp)[1]))
return 0xFF;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/gdisp/gdisp_image_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#define _GDISP_IMAGE_SUPPORT_H

/* Base endian handling routines */
#define gdispImageGetVar(type, p, idx) (*(type *)(((uint8_t *)(p))+(idx)))
#define gdispImageGetVar(type, p, idx) (*(type*) ((intptr_t) p + idx))
#define gdispImageGetByte(type, p, idx, shift) (((type)gdispImageGetVar(uint8_t, p, idx))<<(shift))
#define gdispImageSwap16(w) ((((uint16_t)(w))>>8)|(((uint16_t)(w))<<8))
#define gdispImageSwap32(dw) ((((uint32_t)(w))>>24)|((((uint32_t)(w))&0x00FF0000)>>8)\
Expand Down

0 comments on commit ca3088f

Please sign in to comment.