i agree in principle ;). It probably would be better to
use calloc, within the xmalloc call( as that calloc will zero
out the memory for you ), then malloc.
Although looking at the xmalloc call, I don't know if it's such
a good thing for it to take a 0 length request and turn it into
a 1 byte request. Why would we need to ask for a 0 length portion
of memory?
donald
On Tue, May 02, 2000 at 02:01:09PM -0400, Noel L Yap wrote:
> I've noticed that xmalloc does not zero out the memory that's just been
> allocated. This doesn't jive well when adding new fields to existing structures
> (specially these structures don't have a common constructor-type function to
> initialize the memory). What winds up happening is that these fields contain
> garbage. This is fine when these fields aren't used, but when these fields are
> pointers, they are always used by the function that frees the memory causing a
> core dump.
>
> For safety, I propose that xmalloc zero out the memory it allocates. Any
> comments or rebuttals?
>
> Noel
>
>