pgrep/pkill

Ralf Friedl Ralf.Friedl at online.de
Fri Sep 28 12:14:45 PDT 2007


Tito wrote:
> Maybe this version could be more useful.....
>
> void xfree(void *ptr)
> {
> 	/*	 sets the pointer to NULL
> 		after it has been freed.*/
> 	void **pp = (void **)ptr;
>
> 	if (*pp == NULL) return;
>
> 	free(*pp);
> 	*pp = NULL;
> }
>
>   
You only modify the argument of xfree, not the original pointer.

What you wanted to write is:

void xfree(void **pp)
{
	/*	 sets the pointer to NULL after it has been freed.*/
	if (*pp == NULL) return;
	free(*pp);
	*pp = NULL;
}


Regards
Ralf Friedl


More information about the busybox mailing list