Re: Exceptions in glib



Andreas Bogk <andreas andreas org> writes: 
> Will that be used consistently everywhere? The problem we've been
> discussing was a non-fatal out-of-memory situation. Sure I can call
> g_try_malloc, but what if I call some library function? How should it
> know which malloc to call?
> 
> Thanks for answering my questions, and I hope I'm not beating a dead
> horse here.
> 

Most library functions just call g_malloc() and die on out-of-memory,
because having an error just for that is too inconvenient; users of
the library would always just ignore the error anyway. They already
usually ignore real errors, such as parse errors and stuff.

g_try_malloc() is intended for use where you are allocating a really
large chunk of memory, and thus might expect failure, and also expect
recovery to be possible. gdk_pixbuf_new() is a good example.

Havoc




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