[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FYI: 60-gary-gnulib-xalloc-import2.patch
From: |
Gary V. Vaughan |
Subject: |
FYI: 60-gary-gnulib-xalloc-import2.patch |
Date: |
Thu, 11 Sep 2003 17:43:02 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5b) Gecko/20030903 Thunderbird/0.2 |
Applied to HEAD.
--
())_. 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__/
Index: ChangeLog
from Gary V. Vaughan <address@hidden>
Reimport the latest xalloc module from CVS gnulib, and adjust the
m4 sources to take advantage of xalloc xfree. Also create a new
macro DELETE with the same semantics as the old m4 XFREE macro,
and carefully tweak callers:
* gnulib/config/xalloc.m4, gnulib/m4/xalloc.h: Updated from CVS
gnulib.
* m4/utility.c (xfree): Removed. This function is now supplied by
gnulib xalloc.
* m4/m4private.h (WITH_DMALLOC): Removed XFREE redefine.
* m4/path.c (search_path_add): Use NEW macro from xalloc.h.
* m4/symtab.c (m4_symtab_create): Ditto.
* m4/system_.h: Removed XFREE redefine.
(DELETE): New macro with same functionality as the original m4
XFREE macro, but based on xalloc.h now. Changed all callers.
* src/main.c (main): Use XMALLOC macro.
* m4/hash.c, m4/macro.c, m4/symtab.c, m4/syntax.c: Use xfree
instead of XFREE.
* m4/output.c (m4_output_exit): Use DELETE instead of XFREE.
Index: gnulib/config/xalloc.m4
===================================================================
RCS file: /cvsroot/m4/m4/gnulib/config/xalloc.m4,v
retrieving revision 1.1
diff -u -p -u -r1.1 xalloc.m4
--- gnulib/config/xalloc.m4 10 Sep 2003 17:12:02 -0000 1.1
+++ gnulib/config/xalloc.m4 11 Sep 2003 16:36:41 -0000
@@ -1,4 +1,4 @@
-# xalloc.m4 serial 2
+# xalloc.m4 serial 3
dnl Copyright (C) 2002-2003 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
@@ -8,6 +8,7 @@ dnl the same distribution terms as the r
AC_DEFUN([gl_XALLOC],
[
+ AC_REQUIRE([AC_C_INLINE])
gl_PREREQ_XMALLOC
gl_PREREQ_XSTRDUP
])
Index: gnulib/m4/xalloc.h
===================================================================
RCS file: /cvsroot/m4/m4/gnulib/m4/xalloc.h,v
retrieving revision 1.1
diff -u -p -u -r1.1 xalloc.h
--- gnulib/m4/xalloc.h 10 Sep 2003 17:12:02 -0000 1.1
+++ gnulib/m4/xalloc.h 11 Sep 2003 16:36:41 -0000
@@ -21,6 +21,7 @@
# define XALLOC_H_
# include <stddef.h>
+# include <stdlib.h>
# ifndef __attribute__
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
@@ -61,11 +62,13 @@ char *xstrdup (const char *str);
# define NEW(Type, Var) Type *(Var) = XMALLOC (Type, 1)
/* Free VAR only if non NULL. */
-# define XFREE(Var) \
- do { \
- if (Var) \
- free (Var); \
- } while (0)
+# define XFREE(Var) xfree (Var)
+static inline void
+xfree (void *p)
+{
+ if (p)
+ free (p);
+}
/* Return a pointer to a malloc'ed copy of the array SRC of NUM elements. */
# define CCLONE(Src, Num) \
Index: m4/hash.c
===================================================================
RCS file: /cvsroot/m4/m4/m4/hash.c,v
retrieving revision 1.12
diff -u -p -u -r1.12 hash.c
--- m4/hash.c 27 Aug 2003 17:10:12 -0000 1.12
+++ m4/hash.c 11 Sep 2003 16:36:41 -0000
@@ -134,8 +134,8 @@ m4_hash_delete (m4_hash *hash)
for (i = 0; i < HASH_SIZE (hash); ++i)
if (BUCKET_NTH (hash, i))
bucket_delete (hash, i);
- XFREE (HASH_BUCKETS (hash));
- XFREE (hash);
+ xfree (HASH_BUCKETS (hash));
+ xfree (hash);
}
/* Check that the nodes in bucket I have been cleared, and recycle
@@ -354,7 +354,7 @@ m4_hash_resize (m4_hash *hash, size_t si
bucket_insert (hash, original_buckets[i]);
}
- XFREE (original_buckets);
+ xfree (original_buckets);
}
#endif
@@ -385,7 +385,7 @@ maybe_grow (m4_hash *hash)
bucket_insert (hash, original_buckets[i]);
}
- XFREE (original_buckets);
+ xfree (original_buckets);
}
}
@@ -484,7 +484,7 @@ m4_get_hash_iterator_next (const m4_hash
/* If there are no more nodes to return, recycle the iterator memory. */
if (! (ITERATOR_PLACE (place) || ITERATOR_NEXT (place)))
{
- XFREE (place);
+ xfree (place);
return 0;
}
Index: m4/m4private.h
===================================================================
RCS file: /cvsroot/m4/m4/m4/m4private.h,v
retrieving revision 1.37
diff -u -p -u -r1.37 m4private.h
--- m4/m4private.h 10 Sep 2003 17:12:02 -0000 1.37
+++ m4/m4private.h 11 Sep 2003 16:36:43 -0000
@@ -159,7 +159,7 @@ struct m4_symbol_value {
# define m4_set_symbol_traced(S, V) ((S)->traced = (V))
# define m4_symbol_value_create() (XCALLOC (m4_symbol_value, 1))
-# define m4_symbol_value_delete(V) (XFREE (V))
+# define m4_symbol_value_delete(V) (DELETE (V))
# define m4_is_symbol_value_text(V) ((V)->type == M4_SYMBOL_TEXT)
# define m4_is_symbol_value_func(V) ((V)->type == M4_SYMBOL_FUNC)
@@ -284,11 +284,6 @@ struct m4__search_path_info {
#if WITH_DMALLOC
# define DMALLOC_FUNC_CHECK
# include <dmalloc.h>
-
-/* Dmalloc expects us to use a void returning xfree. */
-# undef XFREE
-# define XFREE(p) (xfree (p))
-
#endif /* WITH_DMALLOC */
/* Other debug stuff. */
Index: m4/macro.c
===================================================================
RCS file: /cvsroot/m4/m4/m4/macro.c,v
retrieving revision 1.40
diff -u -p -u -r1.40 macro.c
--- m4/macro.c 5 Sep 2003 18:32:26 -0000 1.40
+++ m4/macro.c 11 Sep 2003 16:36:43 -0000
@@ -120,7 +120,7 @@ expand_token (m4 *context, m4_obstack *o
abort ();
}
- XFREE (text);
+ xfree (text);
}
Index: m4/output.c
===================================================================
RCS file: /cvsroot/m4/m4/m4/output.c,v
retrieving revision 1.15
diff -u -p -u -r1.15 output.c
--- m4/output.c 27 Aug 2003 17:10:12 -0000 1.15
+++ m4/output.c 11 Sep 2003 16:36:43 -0000
@@ -124,7 +124,7 @@ void
m4_output_exit (void)
{
assert (diversions = 1);
- XFREE (diversion_table);
+ DELETE (diversion_table);
}
Index: m4/path.c
===================================================================
RCS file: /cvsroot/m4/m4/m4/path.c,v
retrieving revision 1.8
diff -u -p -u -r1.8 path.c
--- m4/path.c 27 Aug 2003 17:10:12 -0000 1.8
+++ m4/path.c 11 Sep 2003 16:36:43 -0000
@@ -50,12 +50,11 @@ static void search_path_env_init (m4__se
static void
search_path_add (m4__search_path_info *info, const char *dir)
{
- m4__search_path *path;
+ NEW (m4__search_path, path);
if (*dir == '\0')
dir = ".";
- path = XMALLOC (m4__search_path, 1);
path->next = NULL;
path->len = strlen (dir);
path->dir = xstrdup (dir);
Index: m4/symtab.c
===================================================================
RCS file: /cvsroot/m4/m4/m4/symtab.c,v
retrieving revision 1.45
diff -u -p -u -r1.45 symtab.c
--- m4/symtab.c 27 Aug 2003 17:10:12 -0000 1.45
+++ m4/symtab.c 11 Sep 2003 16:36:45 -0000
@@ -67,7 +67,7 @@ static void * arg_copy_CB (m4_hash *s
m4_symbol_table *
m4_symtab_create (size_t size, bool *nuke_trace_bit)
{
- m4_symbol_table *symtab = XMALLOC (m4_symbol_table, 1);
+ NEW (m4_symbol_table, symtab);
symtab->table = m4_hash_new (size ? size : M4_SYMTAB_DEFAULT_SIZE,
m4_hash_string_hash, m4_hash_string_cmp);
@@ -163,7 +163,7 @@ m4__symtab_remove_module_references (m4_
if (next->type == M4_SYMBOL_TEXT)
xfree (m4_get_symbol_value_text (next));
- XFREE (next);
+ xfree (next);
}
else
data = next;
@@ -280,7 +280,7 @@ m4_symbol_popdef (m4_symbol_table *symta
if (!m4_get_symbol_value (*psymbol))
if (*symtab->nuke_trace_bit || !m4_get_symbol_traced (*psymbol))
{
- XFREE (*psymbol);
+ DELETE (*psymbol);
xfree (m4_hash_remove (symtab->table, name));
}
}
@@ -306,7 +306,7 @@ symbol_popval (m4_symbol *symbol)
}
if (m4_is_symbol_value_text (stale))
xfree (m4_get_symbol_value_text (stale));
- XFREE (stale);
+ xfree (stale);
}
}
@@ -321,7 +321,7 @@ arg_destroy_CB (m4_hash *hash, const voi
assert (hash);
if (SYMBOL_ARG_DEFAULT (token_arg))
- XFREE (SYMBOL_ARG_DEFAULT (token_arg));
+ DELETE (SYMBOL_ARG_DEFAULT (token_arg));
xfree (token_arg);
xfree (m4_hash_remove (hash, (const char *) name));
Index: m4/syntax.c
===================================================================
RCS file: /cvsroot/m4/m4/m4/syntax.c,v
retrieving revision 1.8
diff -u -p -u -r1.8 syntax.c
--- m4/syntax.c 27 Aug 2003 17:10:12 -0000 1.8
+++ m4/syntax.c 11 Sep 2003 16:36:45 -0000
@@ -151,10 +151,10 @@ m4_syntax_delete (m4_syntax_table *synta
{
assert (syntax);
- XFREE (syntax->lquote.string);
- XFREE (syntax->rquote.string);
- XFREE (syntax->bcomm.string);
- XFREE (syntax->ecomm.string);
+ xfree (syntax->lquote.string);
+ xfree (syntax->rquote.string);
+ xfree (syntax->bcomm.string);
+ xfree (syntax->ecomm.string);
xfree (syntax);
}
Index: m4/system_.h
===================================================================
RCS file: /cvsroot/m4/m4/m4/system_.h,v
retrieving revision 1.3
diff -u -p -u -r1.3 system_.h
--- m4/system_.h 10 Sep 2003 17:12:02 -0000 1.3
+++ m4/system_.h 11 Sep 2003 16:36:45 -0000
@@ -153,11 +153,8 @@ BEGIN_C_DECLS
#endif
-/* FIXME: macros to ease transition to gnulib xalloc.h API */
-#undef XFREE
-#define XFREE(Var) ((Var) = xfree (Var))
+#define DELETE(Expr) ((Expr) = (xfree (Expr), (void *) 0))
-extern void *xfree (void *stale);
extern char *xstrzdup (const char *string, size_t len);
END_C_DECLS
Index: m4/utility.c
===================================================================
RCS file: /cvsroot/m4/m4/m4/utility.c,v
retrieving revision 1.39
diff -u -p -u -r1.39 utility.c
--- m4/utility.c 10 Sep 2003 17:12:02 -0000 1.39
+++ m4/utility.c 11 Sep 2003 16:36:45 -0000
@@ -104,12 +104,3 @@ m4_dump_args (m4 *context, m4_obstack *o
}
}
-/* FIXME: merge xfree into gnulib. */
-/* Don't free NULL pointers. */
-void *
-xfree (void *stale)
-{
- if (stale)
- free (stale);
- return 0;
-}
Index: src/main.c
===================================================================
RCS file: /cvsroot/m4/m4/src/main.c,v
retrieving revision 1.51
diff -u -p -u -r1.51 main.c
--- src/main.c 9 Sep 2003 17:15:35 -0000 1.51
+++ src/main.c 11 Sep 2003 16:36:46 -0000
@@ -268,7 +268,7 @@ main (int argc, char *const *argv, char
case 'm':
/* Arguments that cannot be handled until later are accumulated. */
- new = (macro_definition *) xmalloc (sizeof (macro_definition));
+ new = XMALLOC (macro_definition, 1);
new->code = optchar;
new->macro = optarg;
new->next = NULL;
@@ -419,7 +419,7 @@ warranty; not even for MERCHANTABILITY o
for (env = envp; *env != NULL; env++)
{
- new = (macro_definition *) xmalloc (sizeof (macro_definition));
+ new = XMALLOC (macro_definition, 1);
new->code = 'D';
new->macro = *env;
new->next = head;
Index: src/stackovf.c
===================================================================
RCS file: /cvsroot/m4/m4/src/stackovf.c,v
retrieving revision 1.11
diff -u -p -u -r1.11 stackovf.c
--- src/stackovf.c 27 Aug 2003 17:10:13 -0000 1.11
+++ src/stackovf.c 11 Sep 2003 16:36:46 -0000
@@ -414,7 +414,7 @@ Error - Do not know how to catch signals
void
stackovf_exit (void)
{
- XFREE ((void *) stackbuf);
+ DELETE ((void *) stackbuf);
}
#endif /* USE_STACKOVF */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- FYI: 60-gary-gnulib-xalloc-import2.patch,
Gary V. Vaughan <=