* symtab.c (lookup_symbol_in_language): Use a cleanup.
authorTom Tromey <tromey@redhat.com>
Fri, 13 Mar 2009 21:02:58 +0000 (21:02 +0000)
committerTom Tromey <tromey@redhat.com>
Fri, 13 Mar 2009 21:02:58 +0000 (21:02 +0000)
gdb/ChangeLog
gdb/symtab.c

index 3e592a373f5e326c1b6c069e6c9e0903930a7b6e..e29ef67a6c62289530f7bd9c868d907321b73861 100644 (file)
@@ -1,3 +1,7 @@
+2009-03-13  Tom Tromey  <tromey@redhat.com>
+
+       * symtab.c (lookup_symbol_in_language): Use a cleanup.
+
 2009-03-13  Doug Evans  <dje@google.com>
 
        * exceptions.h: Clean up some comments on catch_exceptions usage.
index d2ba1f3dd7e118b96717a08d4239cba5e629a465..7fff68a635bed0981a429d3687c41fa852616da0 100644 (file)
@@ -1197,8 +1197,8 @@ lookup_symbol_in_language (const char *name, const struct block *block,
   char *demangled_name = NULL;
   const char *modified_name = NULL;
   const char *mangled_name = NULL;
-  int needtofreename = 0;
   struct symbol *returnval;
+  struct cleanup *cleanup = make_cleanup (null_cleanup, 0);
 
   modified_name = name;
 
@@ -1211,7 +1211,7 @@ lookup_symbol_in_language (const char *name, const struct block *block,
        {
          mangled_name = name;
          modified_name = demangled_name;
-         needtofreename = 1;
+         make_cleanup (xfree, demangled_name);
        }
     }
   else if (lang == language_java)
@@ -1222,7 +1222,7 @@ lookup_symbol_in_language (const char *name, const struct block *block,
        {
          mangled_name = name;
          modified_name = demangled_name;
-         needtofreename = 1;
+         make_cleanup (xfree, demangled_name);
        }
     }
 
@@ -1241,8 +1241,7 @@ lookup_symbol_in_language (const char *name, const struct block *block,
 
   returnval = lookup_symbol_aux (modified_name, mangled_name, block,
                                 domain, lang, is_a_field_of_this);
-  if (needtofreename)
-    xfree (demangled_name);
+  do_cleanups (cleanup);
 
   return returnval;
 }
This page took 0.035226 seconds and 4 git commands to generate.