Re: Out of memory conditions and g_malloc
- From: "Andrew W. Nosenko" <awn bcs zp ua>
- To: gtk-app-devel-list gnome org
- Subject: Re: Out of memory conditions and g_malloc
- Date: Thu, 25 Sep 2003 00:40:02 +0300
Owen Taylor wrote:
: On Wed, 2003-09-24 at 12:36, Philippe Laporte wrote:
: > "gpointer g_malloc( gulong size );
: >
: > This is a replacement for malloc(). You do not need to check the return
: > value as it is done for you in this function. If the memory allocation
: > fails for whatever reasons, your applications will be terminated.
: > "
: >
: > Is there a way to specify a handler for when memory allocation fails, so
: > that we may have the opportunity to get something more graceful than a
: > terminated application?
:
: g_mem_set_vtable():
:
: http://developer.gnome.org/doc/API/2.0/glib/glib-Memory-Allocation.html#g-mem-set-vtable
:
: allows you to replace the backend function that g_malloc() uses; with
Yet another way -- use g_try_malloc() and handle possible returned NULL
by self.
From Glib Reference Manual:
g_try_malloc ()
Attempts to allocate n_bytes, and returns NULL on failure. Contrast
with g_malloc(), which aborts the program on failure.
--
Andrew W. Nosenko (awn bcs zp ua)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]