[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 10:04:56 +0100 |
On Thursday, September 11, 2003, at 08:59 am, Paul Eggert wrote:
"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);
Fair enough. In which case getting rid of the multiple expansions
would be good enough for me. M4 has container data types that return
their contents when released, and I think this:
XFREE (m4_hash_remove (symtab->table, name));
is cleaner than this:
{
void *stale = m4_hash_remove (symtab->table, name);
XFREE (stale);
}
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)
Okay. I'd also like an equivalent xfree (in xfree.c) so I can:
lt_dlmalloc = xmalloc;
lt_dlrealloc = xrealloc;
lt_dlfree = xfree;
Or even:
#define obstack_chunk_alloc xmalloc
#define obstack_chunk_free xfree
I think an additional module for xfree is too much, but how else to
prototype the function without polluting xalloc.h? Anyway, how's this?
Cheers,
Gary.
2-gary-xfree-module-and-DELETE-macro.patch
Description: Binary data
--
())_. Gary V. Vaughan gary@(oranda.demon.co.uk|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__/
- Re: [Bug-gnulib] Patch proposal: 1-gary-safe-xfree.patch, (continued)
- Re: [Bug-gnulib] Patch proposal: 1-gary-safe-xfree.patch, Jim Meyering, 2003/09/13
- Re: [Bug-gnulib] Patch proposal: 1-gary-safe-xfree.patch, Gary V. Vaughan, 2003/09/15
- Re: [Bug-gnulib] Patch proposal: 1-gary-safe-xfree.patch, Paul Eggert, 2003/09/15
- Re: [Bug-gnulib] Patch proposal: 1-gary-safe-xfree.patch, Gary V . Vaughan, 2003/09/16
- [Bug-gnulib] Re: Patch proposal: 1-gary-safe-xfree.patch, Simon Josefsson, 2003/09/16
- Re: [Bug-gnulib] Patch proposal: 1-gary-safe-xfree.patch, Bruno Haible, 2003/09/15
- Re: [Bug-gnulib] Patch proposal: 1-gary-safe-xfree.patch, Paul Eggert, 2003/09/15
- Re: [Bug-gnulib] Patch proposal: 1-gary-safe-xfree.patch, Bruno Haible, 2003/09/15
- Re: [Bug-gnulib] Patch proposal: 1-gary-safe-xfree.patch, Gary V. Vaughan, 2003/09/19
- Re: [Bug-gnulib] Patch proposal: 1-gary-safe-xfree.patch, Paul Eggert, 2003/09/22
Re: [Bug-gnulib] Patch proposal: 1-gary-safe-xfree.patch,
Gary V . Vaughan <=
Re: [Bug-gnulib] Patch proposal: 1-gary-safe-xfree.patch, Karl Berry, 2003/09/10