[ On Tuesday, May 2, 2000 at 14:01:09 (-0400), Noel L Yap wrote: ]
> Subject: question (preference?) about xmalloc
>
> For safety, I propose that xmalloc zero out the memory it allocates.  Any
> comments or rebuttals?

Generally speaking it is not safe (i.e. not portable) to assume that
memset()ing some allocated storage to all zeros will properly initialise
structure field members, especially not pointers or floats.

Structures who's storage is allocated from the heap should always be
initialised by explicitly assigning known values to all their fields.
Despite the fact that this takes more lines of code it is not normally
more expensive in terms of CPU cycles.

-- 
                                                        Greg A. Woods

+1 416 218-0098      VE3TCP      <[EMAIL PROTECTED]>      <robohack!woods>
Planix, Inc. <[EMAIL PROTECTED]>; Secrets of the Weird <[EMAIL PROTECTED]>

Reply via email to