[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-gnulib] Patch proposal: 1-gary-safe-xfree.patch

From: Paul Eggert
Subject: Re: [Bug-gnulib] Patch proposal: 1-gary-safe-xfree.patch
Date: 11 Sep 2003 00:59:42 -0700
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

"Gary V. Vaughan" <address@hidden> writes:

> This patch does change the semantics of XFREE slightly, but in a
> beneficial way.

The part about evaluating the argument once is nice, but why do you
want XFREE to return NULL?  I find this:

   XFREE (p);
   p = NULL;

to be much clearer than this:

   p = XFREE (p);

Traditionally 'free' returns 'void', and it's confusing to have
XFREE return something else.

How about the following implementation instead?  It evaluates
Var only once.

# define XFREE(Var)                \
   do                              \
     {                             \
       void *to_be_freed = (Var);  \
       if (to_be_freed)            \
         free (to_be_freed);       \
     }                             \
   while (0)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]