[or-cvs] Stupid sizeof operator!
Roger Dingledine
arma at mit.edu
Thu Apr 8 06:48:57 UTC 2004
On Thu, Apr 08, 2004 at 07:41:47AM +0100, Ben Laurie wrote:
> > Log Message:
> > Stupid sizeof operator!
> >
> > - tmp_cpath = tor_malloc_zero(sizeof(tmp_cpath));
> > + tmp_cpath = tor_malloc_zero(sizeof(crypt_path_t));
>
> Errr ... stupid coder, you mean? You wanted:
>
> tmp_cpath = tor_malloc_zero(sizeof *tmp_cpath);
No, I think sizeof(crypt_path_t) is a fine way to do it. It makes it
clearer to me that we're talking about the size of the struct, not the
size of a pointer or something.
I guess it could be a bother if tmp_cpath changes types, but I don't
think that's much of a problem.
--Roger
More information about the tor-dev
mailing list