
On Thu, Mar 22, 2007 at 12:03:10PM +0000, Richard W.M. Jones wrote:
<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.
Understood, but I have yet to get feedback for this portability problems from such an architecture in real life. I'm not sure our compilers would be smart enough to remap to a single zeroing if we were to initialize each field individually, and in that case it's a matter of penalizing all existing architectures in the name of an unexistant one. Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/