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

Stan Shebs shebs@apple.com
Thu May 17 13:24:00 GMT 2001


Michael Snyder wrote:
> 
> One call to memset does a better job than some number of individual assigns,
> esp. since it's guaranteed to get new fields that would be missed otherwise
> (and were being).
> 
> 2001-05-17  Michael Snyder  <msnyder@redhat.com>
> 
>         * blockframe.c (create_new_frame): Zero all the fields via memset,
>         rather than zeroing them one by one.

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.

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

Stan



More information about the Gdb-patches mailing list