bug-gnulib
[Top][All Lists]
Advanced

[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 02:23:28 -0700
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

"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.


> 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.


> Anyway, how's this?

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

This has the problem of evaluating Var twice, e.g.:

  DELETE (foo ()->bar));

will call foo twice.

As I get older, I prefer functions to macros more and more.  For
example, I'd like to decommission XMALLOC, XREALLOC, and CCLONE, since
they don't check for arithmetic overflow in multiplication (which can
lead to serious buffer overrun bugs!), and it's hard to fix that
efficiently in a macro.  The other function-like macros in xalloc.h
should go, too.  (And I say this even though I'm responsible for
writing some of them in the first place.  :-)




reply via email to

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