[gmx-developers] uninitialized data
Erik Lindahl
lindahl at cbr.su.se
Tue Apr 21 21:49:04 CEST 2009
On Apr 21, 2009, at 9:00 PM, David van der Spoel wrote:
> Alexander Herz wrote:
>> of course it must be
>> memset(fr,0,sizeof(t_forcerec)); as fr is a pointer
>
> snew does this.
In practice you're right, but:
1) It is incredibly bad coding habit to rely on the behaviour of
memory allocation for initializing objects.
2) Formally it is even wrong (but so is memset). There is nothing in
the ISO C standard that *requires* NULL to be represented by numerical
0.
Cheers,
Erik
More information about the gromacs.org_gmx-developers
mailing list