[Was] Resolving the licensing issues.

Bernhard Fischer rep.nop at aon.at
Thu Mar 2 13:18:59 PST 2006


On Thu, Mar 02, 2006 at 09:46:58PM +0100, Tito wrote:
>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

Haven't looked at the users, but it sounds like it would be better to
set ptr=NULL in xfree().

That said and without having tried dmalloc with current trunk which has
that patch from vda applied by landley, i think that the free-check of
dmalloc is now not useable anymore, which i'm inclined to think is not a
nice thing to have. YMMV.

Should we perhaps add a .dmallocrc to the tree since we already have an
.ident.pro?



More information about the busybox mailing list