Re: g_malloc() aborts when enough memory is not found?




Mikko Rantalainen <mira@st.jyu.fi> writes:

> While testing exception handling of my program I noticed that when I'm
> using g_malloc() and I'm trying to allocate more memory than it's
> currently available g_malloc calls abort() and thus prevents me from
> handling the problem by myself.
> 
> If I replace g_malloc with plain malloc everything works as expected.
> 
> How I can tell g_malloc not to abort if memory cannot be allocated? GLIB
> "reference" at http://www.gtk.org/docs/glib_toc.html does not help much.

If you need non-aborting behavior, use malloc() ;-)

g_malloc() is basically a wrapper around malloc() that aborts
if memory cannot be allocated. 

[ Right now, there is also the ability to add some simple checking
  into the g_malloc() with compile time options to g_malloc() -
  so you should not mix malloc() and g_free() or vice-versa.
  
  Use of these features is discouraged and they will most likely
  be removed in the feature. ]

Regards,
                                        Owen



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]