Wireshark-dev: Re: [Wireshark-dev] [Wireshark-commits] rev 36988: /trunk/ /trunk/epan/dissector
From: Jakub Zawadzki <[email protected]>
Date: Thu, 5 May 2011 08:51:21 +0200
On Wed, May 04, 2011 at 04:40:12PM -0600, Stephen Fisher wrote:
> On Wed, May 04, 2011 at 09:19:08PM +0000, [email protected] wrote:
> 
> > Log:
> >  XXX, should this code use g_try_malloc instead?
> 
> is that inside GTK+ and GLib, 
> they still use g_malloc, so we can't totally eliminate the 
> possibilty of Wireshark being aborted when out of memory.

Hmm, we could set our own allocator (g_mem_set_vtable()),
and THROW OutOfMemoryError (instead of aborting)

for example vtab.malloc routine:
#v+
static gpointer
ws_malloc(gsize n_bytes)
{
  gpointer ptr = malloc(n_bytes);
  if (!ptr)
    THROW(OutOfMemoryError);
  return ptr;
}
#v-
not tested (I don't have OOM problems ;-))