[libiberty] xmalloc cannot return NULL

Mike Frysinger vapier@gentoo.org
Mon Oct 14 18:04:00 GMT 2013


On Monday 14 October 2013 13:59:16 Marc Glisse wrote:
> libiberty provides a function xmalloc that never returns NULL. However,
> there are some hints that it might be ok if someone wants to supply their
> own xmalloc that can return NULL (though that would break a lot of things,
> including in libiberty itself).
> 
> I would like to remove that freedom, and the point of this email (I hope
> it doesn't bounce from too many of these addresses) is to ask all
> libiberty users if that would cause problems for them. I already heard
> from gcc and gdb that they are happy forbidding a null return value from
> xmalloc.
> 
> Why do I want to do that? I just added an attribute "returns_nonnull" to
> gcc and would like to mark relevant functions, to let the compiler
> optimize based on this property.
> 
> http://gcc.gnu.org/ml/gcc-patches/2013-10/msg00817.html

makes sense to me.  as you point out, we write code based on the assumption 
that NULL is never returned (although, perhaps phrased more accurately, that 
the pointer returned is always valid).
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20131014/b460cb78/attachment.sig>


More information about the Gdb-patches mailing list