Re: [patch 1/5] iptables: fix invalid free

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

 



Daniel Veillard wrote:
On Wed, Mar 21, 2007 at 01:55:35PM +0000, Mark McLoughlin wrote:
- I think the use case is a little different - generally in libvirt, we're only allocating very small chunks where the CPU hit for initialisation would be negligible and would never show up on a
    profile. I'd prefer to take the minor hit of zero-initialising
    most/all memory for programming ease.

- If our wrappers always zero-initialise, we don't need the "initialise to -1 when debugging" thing.

- If we rely on calloc() zero-initialising in our wrappers, we give opportunity for libc to optimise where it knows the memory is already initialised - e.g. where it's mmap()ing the memory from /dev/zero

  okay, okay, let's use calloc() for libvirt, but then there is a number of
places where I probably used memset() for zeroing, they should all be cleaned
up.

<pedant>

Note that neither calloc nor memset really work on unusual architectures where null pointers aren't represented by all-bits-zero. So code like:

struct { void *ptr; } *s;
s = malloc (sizeof (*s));
memset (s, 0, sizeof (*s));
  /* ... */
if (s->ptr == NULL) { do something }

isn't portable.  There's some really strange stuff here about this:

http://www.ex-parrot.com/~chris/random/initialise.html

</pedant>

Rich.

--
Emerging Technologies, Red Hat  http://et.redhat.com/~rjones/
64 Baker Street, London, W1U 7DF     Mobile: +44 7866 314 421
 "[Negative numbers] darken the very whole doctrines of the equations
 and make dark of the things which are in their nature excessively
 obvious and simple" (Francis Maseres FRS, mathematician, 1759)

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]