__uc_malloc hooks

Rob Landley rob at landley.net
Mon Sep 17 17:43:56 UTC 2007


On Monday 17 September 2007 10:08:37 am Dave Dodge wrote:
> On Mon, Sep 17, 2007 at 11:00:23AM +0100, Denys Vlasenko wrote:
> > On Monday 17 September 2007 05:03, Rob Landley wrote:
> > > That said, testing for NULL is seldom useful because attempts to use
> > > the result give you a nice null pointer dereference and a segfault,
> > > cleanly ending the program anyway.
> >
> > For libc, this is not acceptable.
>
> Yeah, this sort of abort-on-oom behavior is exactly what keeps me from
> using glibc's fancy features.  For example the obstack API aborts on
> OOM by default.  It does give the ability to set an error handler, but
> that's still really not good enough because the programs where I
> actually _care_ about these errors tend to be heavily threaded.

Lemme clarify: the correct thing for uClibc to do when it can't allocate 
requested memory is to return either NULL or -ENOMEM back to the calling 
program as appropriate.  It's then userspace's job to test for NULL 
or -ENOMEM.

>                                                   -Dave Dodge

Rob
-- 
"One of my most productive days was throwing away 1000 lines of code."
  - Ken Thompson.



More information about the uClibc mailing list