[patch] VOIDP2INT, INT2VOIDP and pointer size
123 <[email protected]>
| Newsgroups | gmane.comp.web.dillo.devel |
|---|---|
| Message-ID | <[email protected]> |
Now (long) is used for converting (void *) to integer. This patch replaces (long) with intptr_t. I don't think this fixes the real problem. When VOIDP2INT and INT2VOIDP macros are used, it is possible that converted type won't fit into intptr_t. It is better to rewrite code that uses these macros in portable way and remove these macros. Anyway, using intptr_t is better than using (long), (long long) or introducing more autoconf dependency. _______________________________________________ Dillo-dev mailing list [email protected] http://lists.auriga.wearlab.de/cgi-bin/mailman/listinfo/dillo-dev
intptr.patch
(text/plain, 810 B)
diff -r 75ba8829a9f1 dlib/dlib.h --- a/dlib/dlib.h Sun Jun 10 00:15:25 2012 +0200 +++ b/dlib/dlib.h Tue Jun 12 23:08:01 2012 +0400 @@ -5,6 +5,7 @@ #include <stddef.h> /* for size_t */ #include <stdarg.h> /* for va_list */ #include <string.h> /* for strerror */ +#include <stdint.h> /* for intptr_t */ #include "d_size.h" @@ -38,10 +39,8 @@ /* *-- Casts ------------------------------------------------------------------- */ -/* TODO: include a void* size test in configure.in */ -/* (long) works for both 32bit and 64bit */ -#define VOIDP2INT(p) ((long)(p)) -#define INT2VOIDP(i) ((void*)((long)(i))) +#define VOIDP2INT(p) ((intptr_t)(p)) +#define INT2VOIDP(i) ((void*)((intptr_t)(i))) /* *-- Memory -------------------------------------------------------------------