[PATCH] Introduce xmalloc, memory allocator with die_out_of_memory()

Mike Frysinger vapier at gentoo.org
Fri Mar 20 18:30:59 UTC 2015


On 20 Mar 2015 13:30, Dmitry V. Levin wrote:
> On Fri, Mar 20, 2015 at 02:53:39PM +0900, Masatake YAMATO wrote:
> > In strace following code sentences are frequently used:
> > 
> >    var = malloc(fdsize);
> >     if (!var)
> >        die_out_of_memory();
> > 
> > This patch introduces xmalloc and friends which simplify
> > above sentences like:
> > 
> >    var = xmalloc(fdsize);
> > 
> > Here friends are xcalloc and xrealloc.
> 
> Do we need xrealloc in its classic form, or rather an edition
> with an integer overflow check?

a xcalloc variant that doesn't clear memory would be nice (and checks the 
multiplication), although i think we can merge this one as-is and build on
top of it.  is there a standard naming for the array allocator ?
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20150320/f11588c0/attachment.bin>


More information about the Strace-devel mailing list