Ethereal-dev: [Ethereal-dev] g_malloc() vs malloc()

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: "Jim Young" <SYSJHY@xxxxxxxxxxxxxxx>
Date: Wed, 24 Nov 2004 12:40:28 -0500
Hello,

Although the majority of Ethereal's dynamic memory 
allocations appear to use the glib g_malloc()/g_free()
family of routines, I've noticed that several source 
files use the more traditional malloc()/free() family 
of routines.  

While some (most) of these malloc() calls validate
the returned pointer to test for and handle the 
admittedly rare "out-of-memory" case, some of 
the malloc() calls do not.  Modules with un-validated 
malloc() calls include: 

  ./epan/dissectors/packet-manolito.c
  ./follow.c 
  ./gtk/main.c
  ./gtk/tcp_graph.c
  ./gtk/asn1/packet-asn1.c
      
Is their any consensus on the "proper" way to fix these
un-validated malloc()s?  

Should these un-validated malloc() calls be changed 
to use the g_malloc()/g_free() family of routines which 
will handle the "out-of-memory" under the covers (albeit 
not so gracefully) ?

Or should these untested malloc() calls be augmented with
code to test for and "handle" NULL pointers?

I'm looking forward to any hints on the "proper" way to
address this latent problem.

Thanks,

Jim Young