m4-patches
[Top][All Lists]
Advanced

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

FYI: 6-gary-arg-signature-memory-leak.patch


From: Gary V. Vaughan
Subject: FYI: 6-gary-arg-signature-memory-leak.patch
Date: Sat, 14 Jun 2003 12:31:16 +0100
User-agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.3) Gecko/20030312

Commited this on Tuesday, but forgot to mail the patch :-(
--
  ())_. 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__/
Index: ChangeLog
from  Gary V. Vaughan  <address@hidden>

        * m4/symtab.c (m4_symbol_popdef): Need to pass the hash address to
        the destroy callback.
        (m4_arg_destroy): Use the hash address to free the hash node key
        field.

Index: m4/symtab.c
===================================================================
RCS file: /cvsroot/m4/m4/m4/symtab.c,v
retrieving revision 1.31
diff -u -p -r1.31 symtab.c
--- m4/symtab.c 6 Jun 2003 16:14:05 -0000       1.31
+++ m4/symtab.c 10 Jun 2003 11:49:53 -0000
@@ -46,8 +46,8 @@
 
 static int     m4_symbol_destroy       (const void *name, void *symbol,
                                         void *symtab);
-static int     m4_arg_destroy          (const void *ignored, void *arg,
-                                        void *also_ignored);
+static int     m4_arg_destroy          (const void *name, void *arg,
+                                        void *arg_signature);
 
 /* Pointer to symbol table.  */
 m4_hash *m4_symtab = 0;
@@ -220,7 +220,7 @@ m4_symbol_popdef (const char *name)
       if (TOKEN_ARG_SIGNATURE (stale))
        {
          m4_hash_apply (TOKEN_ARG_SIGNATURE (stale),
-                        m4_arg_destroy, NULL);
+                        m4_arg_destroy, TOKEN_ARG_SIGNATURE (stale));
          m4_hash_delete (TOKEN_ARG_SIGNATURE (stale));
        }
       if (TOKEN_TYPE (stale) == M4_TOKEN_TEXT)
@@ -250,13 +250,17 @@ m4_symbol_delete (const char *name)
 /* Callback used by m4_symbol_popdef () to release the memory used
    by values in the arg_signature hash.  */
 static int
-m4_arg_destroy (const void *ignored, void *arg, void *also_ignored)
+m4_arg_destroy (const void *name, void *arg, void *arg_signature)
 {
   struct m4_token_arg *token_arg = (struct m4_token_arg *) arg;
 
+  assert (name);
+  assert (arg_signature);
+
   if (TOKEN_ARG_DEFAULT (token_arg))
     XFREE (TOKEN_ARG_DEFAULT (token_arg));
-  xfree (arg);
+  xfree (token_arg);
+  xfree (m4_hash_remove ((m4_hash *) arg_signature, (const char *) name));
 
   return 0;
 }

reply via email to

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