On Wed, Nov 09, 2011 at 11:09:25PM -0500, Ted Unangst wrote:
> On Thu, Nov 10, 2011, Doug Brewer wrote:
> > I have the following lines in C:
> > 
> > struct foo *bar[10];
> > 
> > If I want to clear out that structure, should I use
> > 
> > memset(bar, 0, sizeof(bar));
> > or
> > memset(bar, 0, sizeof(*bar));
> 
> Your question is quite ambiguous as to "that structure".  There
> are (presumably) 10 structures, somewhere.  And here is an array of
> pointers.
> 
> Neither of your lines will clear out whatever "that structure" can
> reasonably be interpreted to mean.
And note that even memset(bar, 0, sizeof(bar));
will not do anything portable, as you're just zeroing bytes that happen to
be pointers. The result may or may not be valid null pointers...

Reply via email to