diff options
author | Kovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com> | 2009-08-17 20:14:59 +0000 |
---|---|---|
committer | Kovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com> | 2009-08-17 20:14:59 +0000 |
commit | 5417a21bacae422445376efbd080defc827032fb (patch) | |
tree | d0a66f9d6a9dc2be657369abf66a21a3e67c8ca1 | |
parent | 201746a1a161137fa7054244cd17ae981dcb3a2a (diff) | |
download | wireshark-5417a21bacae422445376efbd080defc827032fb.tar.gz wireshark-5417a21bacae422445376efbd080defc827032fb.tar.bz2 wireshark-5417a21bacae422445376efbd080defc827032fb.zip |
As pointed out by Guy, we should probably explain why the gulong -> size_t cast is 'safe'
svn path=/trunk/; revision=29458
-rw-r--r-- | epan/except.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/epan/except.c b/epan/except.c index 8529a8a24a..83d8b95846 100644 --- a/epan/except.c +++ b/epan/except.c @@ -139,6 +139,14 @@ void except_deinit(void) static int init_counter; static void unhandled_catcher(except_t *); static void (*uh_catcher_ptr)(except_t *) = unhandled_catcher; +/* We need this 'size_t' cast due to a glitch in GLib where g_malloc was prototyped + * as 'gpointer g_malloc (gulong n_bytes)'. This was later fixed to the correct prototype + * 'gpointer g_malloc (gsize n_bytes)'. In Wireshark we use the latter prototype + * throughout the code. We can get away with this even with older versions of GLib by + * adding a '(void *(*)(size_t))' cast whenever we refer to g_malloc. The only platform + * supported by Wireshark where this isn't safe (sizeof size_t != sizeof gulong) is Win64. + * However, we _always_ bundle the newest version of GLib on this platform so + * the size_t issue doesn't exists here. Pheew.. */ static void *(*allocator)(size_t) = (void *(*)(size_t)) g_malloc; static void (*deallocator)(void *) = g_free; static struct except_stacknode *stack_top; |