On Wed, 2007-03-21 at 09:07 -0400, Daniel Veillard wrote:
On Wed, Mar 21, 2007 at 12:47:59PM +0000, Mark McLoughlin wrote:
> Replace a few instances of malloc() followed by memset(0) with
> calloc()
Humpf, that's just the opposite of the other parts of libvirt I wrote.
It's more consistent with the rest of libvirt_qemud, though :-)
Could you justify ?
It's hard to catch it's a calloc or a malloc call, and hence notice
if it was initialized or not.
I'm of two minds, really. Previously I would have always done
malloc()/memset() but when using glib I'd tend to use g_new0(). So, it's
handy to have a zeroing allocator.
I guess I never previously relied on calloc() zeroing the memory since
that behaviour isn't reflected in its name.
The extra memset line makes it clear, plus
it will allow me more easilly to plug in libxml2 memory wrapper.
Again, wondering why you'd want to use libxml2's wrapper.
Cheers,
Mark.