diff options
author | Ralph Giles <giles@ghostscript.com> | 2009-08-19 19:22:22 +0200 |
---|---|---|
committer | Ralph Giles <giles@ghostscript.com> | 2009-08-19 19:22:22 +0200 |
commit | fd2ea36e0848223b58c09c292a551b696a955585 (patch) | |
tree | 6a26e4dd05e0ff24382df97c7b46ab7a5e305651 | |
parent | cfeb58fa4694a133e3037b6eccf526389cbffda2 (diff) | |
download | mupdf-fd2ea36e0848223b58c09c292a551b696a955585.tar.xz |
More portable fix for pointer alignments.
The previous patch cast the pointer to (unsigned long) which fixed
a truncation warning on 64 bit Linux, but didn't help on Win64.
Casting to (size_t) is a little more portable, but mupdf doesn't
use that type. Casting to (char*) and substractiong (char*)0
is the best solution for this. It looks a little messy; if more
such checks are added, I suggest moving to a macro:
#define PTR_ALIGN4(ptr) (!((char *)(ptr) - (char *)0) & 3))
However, the pointer in rendersolid() is already an (unsigned) char
pointer. The check in decodetile() is actually checking an unsigned int
pointer for 4-octet alignment, so I don't see how that can ever fail.
-rw-r--r-- | fitzdraw/imageunpack.c | 2 | ||||
-rw-r--r-- | fitzdraw/render.c | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/fitzdraw/imageunpack.c b/fitzdraw/imageunpack.c index 15730479..50a65253 100644 --- a/fitzdraw/imageunpack.c +++ b/fitzdraw/imageunpack.c @@ -48,7 +48,7 @@ static void decodetile(fz_pixmap *pix, int skip, float *decode) if (justinvert) { unsigned *wp = (unsigned *)p; - if (((unsigned long)wp & 3) == 0) { + if ((((char *)wp - (char *)0) & 3) == 0) { int hwh = wh / 2; wh = wh - 2 * hwh; while(hwh--) { diff --git a/fitzdraw/render.c b/fitzdraw/render.c index da06ed83..97941d95 100644 --- a/fitzdraw/render.c +++ b/fitzdraw/render.c @@ -153,7 +153,7 @@ DEBUG("solid %s [%d %d %d %d];\n", solid->cs->name, gc->argb[0], gc->argb[1], gc r = gc->argb[1]; g = gc->argb[2]; b = gc->argb[3]; - if ((unsigned long)p & 3) { + if ((p - (unsigned char *)0) & 3) { while (n--) { p[0] = a; |