m4-patches
[Top][All Lists]
Advanced

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

branch-1_4 no more xfree


From: Eric Blake
Subject: branch-1_4 no more xfree
Date: Sun, 30 Jul 2006 23:35:45 +0000

We were inconsistently using xfree.  xfree is pessimistic on
platforms where free(NULL) works, and not using it was buggy
on platforms where free is broken.  This fixes it, and makes it
easier to maintain - always use free.

2006-07-30  Eric Blake  <address@hidden>

        Use native free when it is good enough.
        * m4/gnulib-cache.m4: Augment with gnulib-tool --import free.
        * src/builtin.c (define_user_macro, m4_regexp, m4_patsubst):
        Adjust calls.
        * src/symtab.c (free_symbol): Likewise.
        * src/m4.c (xfree, main): Likewise.
        * src/m4.h (obstack_chunk_free): Likewise.
        * src/path.c (path_search): Likewise.
        * src/input.c (pop_wrapup, set_quotes, set_comment): Likewise.

Index: m4/gnulib-cache.m4
===================================================================
RCS file: /sources/m4/m4/m4/Attic/gnulib-cache.m4,v
retrieving revision 1.1.2.9
diff -u -p -r1.1.2.9 gnulib-cache.m4
--- m4/gnulib-cache.m4  25 Jul 2006 12:43:56 -0000      1.1.2.9
+++ m4/gnulib-cache.m4  30 Jul 2006 23:32:27 -0000
@@ -15,10 +15,10 @@
 
 
 # Specification in the form of a command-line invocation:
-#   gnulib-tool --import --dir=. --lib=libm4 --source-base=lib --m4-base=m4 
--doc-base=doc --aux-dir=. --macro-prefix=M4 --assume-autoconf=2.60 alloca 
binary-io close-stream error fdl fopen-safer gendocs getopt mkstemp obstack 
regex stdlib-safer strtol tmpfile-safer unlocked-io xalloc xvasprintf
+#   gnulib-tool --import --dir=. --lib=libm4 --source-base=lib --m4-base=m4 
--doc-base=doc --aux-dir=. --macro-prefix=M4 alloca binary-io close-stream 
error fdl fopen-safer free gendocs getopt mkstemp obstack regex stdlib-safer 
strtol tmpfile-safer unlocked-io xalloc xvasprintf
 
 # Specification in the form of a few gnulib-tool.m4 macro invocations:
-gl_MODULES([alloca binary-io close-stream error fdl fopen-safer gendocs getopt 
mkstemp obstack regex stdlib-safer strtol tmpfile-safer unlocked-io xalloc 
xvasprintf])
+gl_MODULES([alloca binary-io close-stream error fdl fopen-safer free gendocs 
getopt mkstemp obstack regex stdlib-safer strtol tmpfile-safer unlocked-io 
xalloc xvasprintf])
 gl_AVOID([])
 gl_SOURCE_BASE([lib])
 gl_M4_BASE([m4])
@@ -26,4 +26,3 @@ gl_DOC_BASE([doc])
 gl_TESTS_BASE([tests])
 gl_LIB([libm4])
 gl_MACRO_PREFIX([M4])
-gl_AUTOCONF_MINVERSION([2.60])
Index: src/builtin.c
===================================================================
RCS file: /sources/m4/m4/src/Attic/builtin.c,v
retrieving revision 1.1.1.1.2.29
diff -u -p -r1.1.1.1.2.29 builtin.c
--- src/builtin.c       30 Jul 2006 03:18:12 -0000      1.1.1.1.2.29
+++ src/builtin.c       30 Jul 2006 23:32:27 -0000
@@ -230,7 +230,7 @@ define_user_macro (const char *name, con
 
   s = lookup_symbol (name, mode);
   if (SYMBOL_TYPE (s) == TOKEN_TEXT)
-    xfree (SYMBOL_TEXT (s));
+    free (SYMBOL_TEXT (s));
 
   SYMBOL_TYPE (s) = TOKEN_TEXT;
   SYMBOL_TEXT (s) = xstrdup (text);
@@ -1725,7 +1725,7 @@ m4_regexp (struct obstack *obs, int argc
 
   length = strlen (victim);
   startpos = re_search (&buf, victim, length, 0, length, &regs);
-  xfree (buf.buffer);
+  free (buf.buffer);
 
   if (startpos  == -2)
     {
@@ -1780,8 +1780,7 @@ m4_patsubst (struct obstack *obs, int ar
     {
       M4ERROR ((warning_status, 0,
                "bad regular expression `%s': %s", regexp, msg));
-      if (buf.buffer != NULL)
-       xfree (buf.buffer);
+      free (buf.buffer);
       return;
     }
 
@@ -1828,7 +1827,7 @@ m4_patsubst (struct obstack *obs, int ar
     }
   obstack_1grow (obs, '\0');
 
-  xfree (buf.buffer);
+  free (buf.buffer);
   return;
 }
 
Index: src/input.c
===================================================================
RCS file: /sources/m4/m4/src/Attic/input.c,v
retrieving revision 1.1.1.1.2.12
diff -u -p -r1.1.1.1.2.12 input.c
--- src/input.c 28 Jul 2006 20:39:37 -0000      1.1.1.1.2.12
+++ src/input.c 30 Jul 2006 23:32:28 -0000
@@ -348,12 +348,12 @@ boolean
 pop_wrapup (void)
 {
   obstack_free (current_input, NULL);
-  xfree (current_input);
+  free (current_input);
 
   if (wsp == NULL)
     {
       obstack_free (wrapup_stack, NULL);
-      xfree (wrapup_stack);
+      free (wrapup_stack);
       return FALSE;
     }
 
@@ -619,8 +619,8 @@ input_init (void)
 void
 set_quotes (const char *lq, const char *rq)
 {
-  xfree (lquote.string);
-  xfree (rquote.string);
+  free (lquote.string);
+  free (rquote.string);
 
   lquote.string = xstrdup (lq ? lq : DEF_LQUOTE);
   lquote.length = strlen (lquote.string);
@@ -631,8 +631,8 @@ set_quotes (const char *lq, const char *
 void
 set_comment (const char *bc, const char *ec)
 {
-  xfree (bcomm.string);
-  xfree (ecomm.string);
+  free (bcomm.string);
+  free (ecomm.string);
 
   bcomm.string = xstrdup (bc ? bc : DEF_BCOMM);
   bcomm.length = strlen (bcomm.string);
Index: src/m4.c
===================================================================
RCS file: /sources/m4/m4/src/Attic/m4.c,v
retrieving revision 1.1.1.1.2.23
diff -u -p -r1.1.1.1.2.23 m4.c
--- src/m4.c    30 Jul 2006 03:18:12 -0000      1.1.1.1.2.23
+++ src/m4.c    30 Jul 2006 23:32:28 -0000
@@ -115,23 +115,6 @@ stackovf_handler (void)
 
 #endif /* USE_STACKOV */
 
-/* Memory allocation.  */
-
-/*------------------------.
-| Failsafe free routine.  |
-`------------------------*/
-
-#ifdef WITH_DMALLOC
-# undef xfree
-#endif
-
-void
-xfree (void *p)
-{
-  if (p != NULL)
-    free (p);
-}
-
 
 /*---------------------------------------------.
 | Print a usage message and exit with STATUS.  |
@@ -476,7 +459,7 @@ Written by Rene' Seindal.\n\
        }
 
       next = defines->next;
-      xfree (defines);
+      free (defines);
       defines = next;
     }
 
Index: src/m4.h
===================================================================
RCS file: /sources/m4/m4/src/m4.h,v
retrieving revision 1.1.1.1.2.22
diff -u -p -r1.1.1.1.2.22 m4.h
--- src/m4.h    30 Jul 2006 03:18:12 -0000      1.1.1.1.2.22
+++ src/m4.h    30 Jul 2006 23:32:28 -0000
@@ -84,9 +84,8 @@ struct string
 typedef struct string STRING;
 
 /* Memory allocation.  */
-void xfree (void *);
 #define obstack_chunk_alloc    xmalloc
-#define obstack_chunk_free     xfree
+#define obstack_chunk_free     free
 
 /* Those must come first.  */
 typedef struct token_data token_data;
Index: src/path.c
===================================================================
RCS file: /sources/m4/m4/src/Attic/path.c,v
retrieving revision 1.1.1.1.2.6
diff -u -p -r1.1.1.1.2.6 path.c
--- src/path.c  30 Jul 2006 03:18:12 -0000      1.1.1.1.2.6
+++ src/path.c  30 Jul 2006 23:32:28 -0000
@@ -162,7 +162,7 @@ path_search (const char *file, const cha
          return fp;
        }
     }
-  xfree (name);
+  free (name);
   errno = e;
   return fp;
 }
Index: src/symtab.c
===================================================================
RCS file: /sources/m4/m4/src/Attic/symtab.c,v
retrieving revision 1.1.1.1.2.12
diff -u -p -r1.1.1.1.2.12 symtab.c
--- src/symtab.c        7 Jul 2006 20:20:38 -0000       1.1.1.1.2.12
+++ src/symtab.c        30 Jul 2006 23:32:28 -0000
@@ -144,11 +144,10 @@ free_symbol (symbol *sym)
     SYMBOL_DELETED (sym) = TRUE;
   else
     {
-      if (SYMBOL_NAME (sym))
-       xfree (SYMBOL_NAME (sym));
+      free (SYMBOL_NAME (sym));
       if (SYMBOL_TYPE (sym) == TOKEN_TEXT)
-       xfree (SYMBOL_TEXT (sym));
-      xfree (sym);
+       free (SYMBOL_TEXT (sym));
+      free (sym);
     }
 }
 




reply via email to

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