[PATCH 1/4] mempool: use wide enough type for pointer arithmetic

Simon Richter <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
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

-- 
cairo mailing list
[email protected]
https://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.