pspp-dev
[Top][All Lists]
Advanced

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

xcalloc / xmalloc


From: John Darrington
Subject: xcalloc / xmalloc
Date: Mon, 23 May 2005 18:29:15 +0800
User-agent: Mutt/1.5.6+20040907i

alloc.c contains a function called xcalloc, which is like xmalloc except that
it initialises it's memory to zero.  

I suggest that we 

1.  Rename xcalloc to something like zmalloc.

2.  Implement an xcalloc function which wraps calloc, in the same way that
    xmalloc wraps malloc. 

3.  Prefer the new xcalloc where appropriate.  Ie: rather than:

        xmalloc(n_things * sizeof *things);

    use

        xcalloc(n_things, sizeof *things);

    The former raises the possibility of integer overflow and hence buffer 
    overrun.  In the latter case, we have more opportunity for bounds checking.


        





-- 
PGP Public key ID: 1024D/2DE827B3 
fingerprint = 8797 A26D 0854 2EAB 0285  A290 8A67 719C 2DE8 27B3
See http://pgp.mit.edu or any PGP keyserver for public key.


Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]