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 /fitzdraw/render.c | |
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.
Diffstat (limited to 'fitzdraw/render.c')
-rw-r--r-- | fitzdraw/render.c | 2 |
1 files changed, 1 insertions, 1 deletions
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; |