[Was] Resolving the licensing issues.
Tito
farmatito at tiscali.it
Thu Mar 2 20:46:58 UTC 2006
On Thursday 02 March 2006 20:49, Rob Landley wrote:
snip
> I also checked the free() man page, which says:
>
> free() frees the memory space pointed to by ptr, which must have been
> returned by a previous call to malloc(), calloc() or realloc(). Other‐
> wise, or if free(ptr) has already been called before, undefined
> behaviour occurs. If ptr is NULL, no operation is performed.
>
snip
> The Open Group Base Specifications, Version 6 say "If ptr is a null pointer,
> no action shall occur.", which you can check for yourself here:
> http://www.opengroup.org/onlinepubs/009695399/functions/free.html
>
> So free(NULL) doing nothing is explicitly documented behavior, and it's
> smaller. Relying on this is not exactly a huge gamble.
>
snip
>Rob
Why not:
void *xfree(void *ptr)
{
/* sets the pointer to NULL after it has been freed. */
free(ptr);
return NULL;
}
to use as:
ptr = xfree(ptr);
so all double free errors should be avoided.
Just an idea, maybe not the smartest...... :-P
Ciao,
Tito
More information about the busybox
mailing list