Re: xmalloc string functions



ymuntyan@xxxxxxxxx wrote:

But it's not true, there are ifs and buts. Using glib, you *can*
do stuff when malloc() fails. Yes, using glib all you sensibly
can do on malloc() failure is some sort of emergency work and
quit. If your application requires more, then you don't want to
use glib, that's it. But I claim that for 'regular' desktop
applications that is quite enough.

If your regular desktop application is a clock, perhaps. If it holds any
user input, and for this the application can be as simple as a
calculator, it is not nearly enough. Consider how irritating it would be
to type half a dozen numbers, of twenty digits each, and a handful of
operations, only to have your application crash because it could not get
the memory for that last comlpex calculation. At the very least, your
app should put up a message box saying "Out of memory - could not
compute", and then let you copy the previous twenty-digit result into
another document for safe keeping. But no, it crashed, taking not just
the final computation but also all intermediate results with it. Now you
have nothing, when you _could_ have had something to work from. Thank
you, glib.

Richard
.



Relevant Pages

  • Re: xmalloc string functions
    ... malloc() failure is some sort of emergency work and quit. ... application requires more, then you don't want to use glib, that's it. ... the memory for that last comlpex calculation. ...
    (comp.lang.c)
  • Re: xmalloc string functions
    ... malloc() failure is some sort of emergency work and quit. ... application requires more, then you don't want to use glib, that's it. ... the memory for that last comlpex calculation. ... Some of us have and have already suggested having and using a buffer that is large enough for the emergency action. ...
    (comp.lang.c)
  • Re: xmalloc string functions
    ... And a code parser which will find all malloc() calls, ... pointer, or an allocation failure - you know, the very thing we're ... *before* you terminate the application. ... Glib doesn't do anything but abort ...
    (comp.lang.c)
  • Re: [RFC 0/3] Recursive reclaim (on __PF_MEMALLOC)
    ... Once the memory requirements of a userspace daemon ... Yes, and also inspect the code to ensure it doesn't violate mlock_all by execing programs, dynamically loading libraries, etc. ... In nbd-server, there's no dlopen, and I do not currently plan to add ... Avoiding glib is a good start. ...
    (Linux-Kernel)
  • Re: xmalloc string functions
    ... though replace and getquote are non-trivial. ... none of these functions can ever return null for out of memory ... glib is where bad ideas go to die. ... gint main (gint argc, gchar **argv) ...
    (comp.lang.c)