Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Oct 1995 16:01:46 -0400
From:      "Garrett A. Wollman" <wollman@lcs.mit.edu>
To:        Nate Williams <nate@rocky.sri.MT.net>
Cc:        current@freebsd.org
Subject:   Re: tail dumps core
Message-ID:  <9510102001.AA10553@halloran-eldar.lcs.mit.edu>
In-Reply-To: <199510101943.NAA22092@rocky.sri.MT.net>
References:  <9510101735.AA10192@halloran-eldar.lcs.mit.edu> <199510101836.LAA10827@phaeton.artisoft.com> <9510101901.AA10410@halloran-eldar.lcs.mit.edu> <199510101943.NAA22092@rocky.sri.MT.net>

next in thread | previous in thread | raw e-mail | index | archive | help
<<On Tue, 10 Oct 1995 13:43:32 -0600, Nate Williams <nate@rocky.sri.MT.net> said:

> So, what's your point?  Other than some comments in this set of lines

> which implies that memset doesn't have to set an integer to all zeros,
> what's the problem?  How does the C standard allow for memseting an int
> to be non-zero?

The same way it allows for memsetting a pointer to be non-NULL: it
makes no guarantees whatsoever about the underlying bitwise
representation of its data types in memory.

> Also, you made the assertion that calloc() is almost never necessary.  I
> charge you to backup that statement, since I often use structures which
> I must explicity zero out all of the members, and using calloc() and/or
>  malloc/memset is a big performance win compared to zero'ing out every
> single member of the struct.

Explicitly zeroing out every single member of a structure is the ONLY
way the C Standard provides to set each member to an appropriate zero
value for its type, except in the limited situation where every
element of the array is of type `char' or `char []'.

My point in saying this is not to say that for all practical purposes
you can't depend on this, but rather to say that arguments suggesting
that `calloc' is somehow ``more portable'' are completely specious.

-GAWollman

--
Garrett A. Wollman   | Shashish is simple, it's discreet, it's brief. ... 
wollman@lcs.mit.edu  | Shashish is the bonding of hearts in spite of distance.
Opinions not those of| It is a bond more powerful than absence.  We like people
MIT, LCS, ANA, or NSA| who like Shashish.  - Claude McKenzie + Florent Vollant



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9510102001.AA10553>