Wireshark-dev: Re: [Wireshark-dev] Except.c build errors
From: Guy Harris <guy@xxxxxxxxxxxx>
Date: Mon, 17 Aug 2009 11:44:26 -0700

On Aug 16, 2009, at 9:32 PM, Kovarththanan Rajaratnam wrote:

Hey,

Martin Mathieson wrote:
Hi,

I was seeing error messages, because my compiler (gcc 3.4.6) wouldn't
allow except_set_allocator() to cast the function prototype that
differed by its arg (i.e. the length field from size_t to gulong (as
used  by g_malloc()).

The attached patch works for me - should it be checked in?

I think we should just add a typecast here.

I'm not sure that casting a pointer to g_malloc() to a pointer to a function taking a size_t as an argument would work on platforms where sizeof(size_t) != sizeof(gulong); Win64 is, as far as I know, one such platform, as it's LLP64, so "gulong" is 32 bits and "size_t" is 64 bits, and we do support Win64.

I really wish the GLib people had used gsize in a bunch of their APIs; gulong and size_t are the same size in ILP32 and LP64 platforms, so the only place where fixing that would cause problems would be LLP64 platforms such as Win64. Whether they *will* fix it is another matter....

I would vote either for using Martin's patch or for writing a wrapper around g_malloc() that takes a size_t as an argument.