[PATCH] use memset to zero the fields of a new frame_info

Andrew Cagney ac131313@cygnus.com
Thu May 17 21:04:00 GMT 2001


> Ah, the end of an era.  Gilmore originally objected to this kind of
> thing, on the theory that it was "machine-gunning" memory and wasn't
> necessary - only set fields that you know need to be zeroed.  I'm on
> the fence, because it can save bugs and random scattered init code
> if you can assume that newly-allocated data all has known values, and
> clearing small-to-medium-size structs isn't expensive usually.


I remember that, I got my wrist slapped for sending such a patch to BFD.


> In any case, the policy ought to be clarified one way or the other.


If you look at PSIM which uses ZALLOC(TYPE) (allocate sizeof(TYPE) bytes 
of zero initialized memory) you'll see where I sit.

When it comes down to it, I'm more concerned with ensuring that all 
memory is initialized to a well defined, machine independant, value then 
what the value actually is.  Zero happens to be convenient.

	Andrew




More information about the Gdb-patches mailing list