Re: core segfaults (Yahoo?)

Philip S Tellis <[email protected]> Fri, 12 Mar 2004 11:22:28 +0530 (IST)
Newsgroups gmane.network.everybuddy.devel
Message-ID <[email protected]>
Sometime on Mar 11, A. Craig West assembled some asciibets to say:

> > > +  free(plugin->info);
> > > +  free(plugin->errormsg);
> > ...but then, if there's an error, we create the plugin with NULL info 
> > and errormsg, and then free them straight away. Huh?
> 
> If they are NULL, free does nothing, so we don't lose much. I added

I think free crashes if you free(NULL);

I generally have this:

#define FREE(x)	while(x) {free(x);x=NULL;}

Use the while instead of an if, because the if could cause problems if 
nested:

if(foo)	FREE(x);
else	bar(foo);

-- 
Nothing is so firmly believed as that which we least know.
		-- Michel de Montaigne