[Was] Resolving the licensing issues.

Denis Vlasenko vda at ilport.com.ua
Fri Mar 3 02:07:24 PST 2006


On Friday 03 March 2006 11:29, Steven Scholz wrote:
> Bernd Petrovitsch wrote:
> 
> > or
> > #define FREE(p) do { free(p); (p) = NULL; } while(0)
> 
> I suggest
> #define xfree(p) do { free(p); (p) = NULL; } while(0)

One will be rather confused by gcc error message in this case:

	xfree(wrapperfunc());

BTW, ext2fs code already has "free which also sets ptr to NULL"
and it takes a pointer to pointer:

errcode_t ext2fs_free_mem(void *ptr)
{
        void **pp = (void **)ptr;
        free(*pp);
        *pp = 0;
        return 0;
}
(Wow. why does it return a value?)

Users explicitly take address: ext2fs_free_mem(&p);


Another thing. xfree(), xmalloc() etc are rather non-informative:

xfree - free and set to null? or free if CONFIG_FEATURE_CLEAN_UP?

I think it makes sense to give more meaningful names:
free_and_null(), malloc_or_die().
--
vda


More information about the busybox mailing list