[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: Gary V. Vaughan
Subject: Re: [Bug-gnulib] Patch proposal: 1-gary-safe-xfree.patch
Date: Thu, 11 Sep 2003 12:39:42 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5b) Gecko/20030903 Thunderbird/0.2

Paul Eggert wrote:
"Gary V.Vaughan" <address@hidden> writes:
I'd also like an equivalent xfree (in xfree.c) so I can:

    lt_dlfree    = xfree;

The patch I most recently proposed allows that, since you can assign
the address of an inline function to a variable.  You might get
different function addresses in different modules, but I assume that's
OK here.

Agreed. I imagine that it would be rare indeed, even in the case of registering cleanup handlers throughout client code, to need to compare the addresses of such function pointers. Your patch definitely suits me :-)

how else to prototype the function without polluting xalloc.h?

I think xalloc.h is the natural place for this, so it's not pollution.

I meant in my patch, where xfree was a separate module.  Your solution is 

Anyway, how's this?

+# define DELETE(Var)   \
+   do {                        \
+      XFREE (Var);     \
+      Var = 0;         \
+   } while (0)

This has the problem of evaluating Var twice

I don't think that matters, as long as clients are aware of the convention that function like macros (with uppercase symbol names) may evaluate arguments multiple times: A common style of C programming.

However, it is easy to fix if that is important. Either way, I think DELETE is a nice complement to NEW, but would be delighted to see your latest xfree patch applied with or without :-)

As I get older, I prefer functions to macros more and more.

If you can assume C89, static inline functions are definitely better than preprocessor macros. My coding style has avoided side effects in uppercase macro parameters for so long that I'm hardly aware of my doing it now.

  ())_.  Gary V. Vaughan    gary@(lilith.warpmail.net|gnu.org)
  ( '/   Research Scientist http://www.oranda.demon.co.uk       ,_())____
  / )=   GNU Hacker         http://www.gnu.org/software/libtool  \'      `&
`(_~)_   Tech' Author       http://sources.redhat.com/autobook   =`---d__/

reply via email to

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