diff options
author | Rob Kendrick <rjek@netsurf-browser.org> | 2008-04-07 10:23:18 +0000 |
---|---|---|
committer | Rob Kendrick <rjek@netsurf-browser.org> | 2008-04-07 10:23:18 +0000 |
commit | 7614b2694466d490ea150b2dd33766d4c1015e7f (patch) | |
tree | f1946abfa392c97c2c663296e25473f3bf37958d | |
parent | 384327a2795f2df009680c6fe7c5278f1e92f1d5 (diff) | |
download | netsurf-7614b2694466d490ea150b2dd33766d4c1015e7f.tar.gz netsurf-7614b2694466d490ea150b2dd33766d4c1015e7f.tar.bz2 |
Fix assumption that int is the same width as a pointer
svn path=/trunk/netsurf/; revision=4081
-rw-r--r-- | image/bmpread.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/image/bmpread.c b/image/bmpread.c index f8ae53cc0..161145b56 100644 --- a/image/bmpread.c +++ b/image/bmpread.c @@ -21,6 +21,7 @@ #include <stdio.h> #include <string.h> #include <stdlib.h> +#include <stdint.h> #include "image/bmpread.h" #include "image/bitmap.h" #include "utils/log.h" @@ -303,7 +304,7 @@ bmp_result bmp_analyse_header(struct bmp_image *bmp, char *data) { bmp->colour_table = NULL; return BMP_INSUFFICIENT_MEMORY; } - bmp->bitmap_offset = (int)data - (int)bmp->bmp_data; + bmp->bitmap_offset = (intptr_t)data - (intptr_t)bmp->bmp_data; bitmap_set_suspendable(bmp->bitmap, bmp, bmp_invalidate); return BMP_OK; } @@ -401,7 +402,7 @@ bmp_result bmp_decode(struct bmp_image *bmp) { if ((!bmp->ico) || (result != BMP_OK)) return result; - bytes = (int)bmp->bmp_data + bmp->buffer_size - (int)data; + bytes = (intptr_t)bmp->bmp_data + bmp->buffer_size - (intptr_t)data; return bmp_decode_mask(bmp, data, bytes); } @@ -426,12 +427,12 @@ bmp_result bmp_decode_rgb24(struct bmp_image *bmp, char **start, int bytes) { top = bitmap_get_buffer(bmp->bitmap); bottom = top + swidth * (bmp->height - 1); end = data + bytes; - addr = ((unsigned int)data) & 3; + addr = ((intptr_t)data) & 3; skip = bmp->bpp >> 3; bmp->decoded = true; for (y = 0; y < bmp->height; y++) { - while (addr != (((unsigned int)data) & 3)) + while (addr != (((intptr_t)data) & 3)) data++; if ((data + (skip * bmp->width)) > end) return BMP_INSUFFICIENT_DATA; @@ -486,11 +487,11 @@ bmp_result bmp_decode_rgb16(struct bmp_image *bmp, char **start, int bytes) { top = bitmap_get_buffer(bmp->bitmap); bottom = top + swidth * (bmp->height - 1); end = data + bytes; - addr = ((unsigned int)data) & 3; + addr = ((intptr_t)data) & 3; bmp->decoded = true; for (y = 0; y < bmp->height; y++) { - if (addr != (((unsigned int)data) & 3)) + if (addr != (((intptr_t)data) & 3)) data += 2; if ((data + (2 * bmp->width)) > end) return BMP_INSUFFICIENT_DATA; @@ -553,11 +554,11 @@ bmp_result bmp_decode_rgb(struct bmp_image *bmp, char **start, int bytes) { top = bitmap_get_buffer(bmp->bitmap); bottom = top + swidth * (bmp->height - 1); end = data + bytes; - addr = ((unsigned int)data) & 3; + addr = ((intptr_t)data) & 3; bmp->decoded = true; for (y = 0; y < bmp->height; y++) { - while (addr != (((unsigned int)data) & 3)) + while (addr != (((intptr_t)data) & 3)) data++; bit = 32; if ((data + (bmp->width / ppb)) > end) @@ -599,10 +600,10 @@ bmp_result bmp_decode_mask(struct bmp_image *bmp, char *data, int bytes) { top = bitmap_get_buffer(bmp->bitmap); bottom = top + swidth * (bmp->height - 1); end = data + bytes; - addr = ((unsigned int)data) & 3; + addr = ((intptr_t)data) & 3; for (y = 0; y < bmp->height; y++) { - while (addr != (((unsigned int)data) & 3)) + while (addr != (((intptr_t)data) & 3)) data++; if ((data + (bmp->width >> 3)) > end) return BMP_INSUFFICIENT_DATA; |