[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [or-cvs] Stupid sizeof operator!



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