Re: Memory allocation troubles



On Wed, 20 Oct 2004 19:00:55 +0300, Paul Pogonyshev <pogonyshev gmx net> wrote:
Tristan Van Berkom wrote:
On Wed, 20 Oct 2004 02:00:29 +0300, Paul Pogonyshev <pogonyshev gmx net> wrote:
[...]
Oh, I just remembered that you can use your own malloc() implementation
with Glib/GTK+!  So, while this doesn't solve your problem out of the box,
you can do something like this:

This doesn't help,
     gtk+ is written with the assumption that its all-or-nothing
(memory available
or abort), so even if your implementation of malloc returns NULL
(which I think is
asserted anyway outside your implementation) then you'd have functions like
g_object_new() segfaulting instead of returning NULL (i.e. someone in
gtk_something_init() will allocate something, fail, access it and segfault).

Did you even care to read the function?  It could never return NULL.

Sorry, admitedly I didn't.

I guess it would be possible also to implement some kind of OOM exception
handler through g_mem_set_vtable(), even that smells like a hack though.

Cheers,
                                       -Tristan



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