[cairo] [PATCH 1/4] mempool: use wide enough type for pointer arithmetic
Simon Richter
Simon.Richter at hogyros.de
Wed Feb 10 21:49:05 CET 2016
The "unsigned long" type on Windows is just 32 bits wide, so converting
from and to a pointer is unsafe.
Replace this with intptr_t, which is guaranteed to be wide enough. It would
be better to use uintptr_t here, but this is not available in several MSVC
versions.
---
src/cairo-mempool.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/cairo-mempool.c b/src/cairo-mempool.c
index 751ede3..d177bcc 100644
--- a/src/cairo-mempool.c
+++ b/src/cairo-mempool.c
@@ -284,19 +284,19 @@ _cairo_mempool_init (cairo_mempool_t *pool,
void *base, size_t bytes,
int min_bits, int num_sizes)
{
- unsigned long tmp;
+ intptr_t tmp;
int num_blocks;
int i;
/* Align the start to an integral chunk */
- tmp = ((unsigned long) base) & ((1 << min_bits) - 1);
+ tmp = ((intptr_t) base) & ((1 << min_bits) - 1);
if (tmp) {
tmp = (1 << min_bits) - tmp;
base = (char *)base + tmp;
bytes -= tmp;
}
- assert ((((unsigned long) base) & ((1 << min_bits) - 1)) == 0);
+ assert ((((intptr_t) base) & ((1 << min_bits) - 1)) == 0);
assert (num_sizes < ARRAY_LENGTH (pool->free));
pool->base = base;
--
2.1.4
More information about the cairo
mailing list