Use gdb::unique_xmalloc_ptr when calling tilde_expand
[deliverable/binutils-gdb.git] / gdb / symmisc.c
index cfdd5d940bdf6c1107b255525a835a0d2b99d4a7..c85f0b715c96b9056ecc741c761425713ebb2e81 100644 (file)
@@ -408,14 +408,12 @@ static void
 maintenance_print_symbols (char *args, int from_tty)
 {
   struct ui_file *outfile = gdb_stdout;
-  struct cleanup *cleanups;
   char *address_arg = NULL, *source_arg = NULL, *objfile_arg = NULL;
   int i, outfile_idx;
 
   dont_repeat ();
 
   gdb_argv argv (args);
-  cleanups = make_cleanup (null_cleanup, NULL);
 
   for (i = 0; argv != NULL && argv[i] != NULL; ++i)
     {
@@ -460,14 +458,12 @@ maintenance_print_symbols (char *args, int from_tty)
 
   if (argv != NULL && argv[outfile_idx] != NULL)
     {
-      char *outfile_name;
-
       if (argv[outfile_idx + 1] != NULL)
        error (_("Junk at end of command"));
-      outfile_name = tilde_expand (argv[outfile_idx]);
-      make_cleanup (xfree, outfile_name);
-      if (!arg_outfile.open (outfile_name, FOPEN_WT))
-       perror_with_name (outfile_name);
+      gdb::unique_xmalloc_ptr<char> outfile_name
+       (tilde_expand (argv[outfile_idx]));
+      if (!arg_outfile.open (outfile_name.get (), FOPEN_WT))
+       perror_with_name (outfile_name.get ());
       outfile = &arg_outfile;
     }
 
@@ -519,8 +515,6 @@ maintenance_print_symbols (char *args, int from_tty)
       if (source_arg != NULL && !found)
        error (_("No symtab for source file: %s"), source_arg);
     }
-
-  do_cleanups (cleanups);
 }
 
 /* Print symbol ARGS->SYMBOL on ARGS->OUTFILE.  ARGS->DEPTH says how
@@ -709,7 +703,6 @@ static void
 maintenance_print_msymbols (char *args, int from_tty)
 {
   struct ui_file *outfile = gdb_stdout;
-  struct cleanup *cleanups;
   char *objfile_arg = NULL;
   struct objfile *objfile;
   int i, outfile_idx;
@@ -717,7 +710,6 @@ maintenance_print_msymbols (char *args, int from_tty)
   dont_repeat ();
 
   gdb_argv argv (args);
-  cleanups = make_cleanup (null_cleanup, NULL);
 
   for (i = 0; argv != NULL && argv[i] != NULL; ++i)
     {
@@ -747,14 +739,12 @@ maintenance_print_msymbols (char *args, int from_tty)
 
   if (argv != NULL && argv[outfile_idx] != NULL)
     {
-      char *outfile_name;
-
       if (argv[outfile_idx + 1] != NULL)
        error (_("Junk at end of command"));
-      outfile_name = tilde_expand (argv[outfile_idx]);
-      make_cleanup (xfree, outfile_name);
-      if (!arg_outfile.open (outfile_name, FOPEN_WT))
-       perror_with_name (outfile_name);
+      gdb::unique_xmalloc_ptr<char> outfile_name
+       (tilde_expand (argv[outfile_idx]));
+      if (!arg_outfile.open (outfile_name.get (), FOPEN_WT))
+       perror_with_name (outfile_name.get ());
       outfile = &arg_outfile;
     }
 
@@ -765,8 +755,6 @@ maintenance_print_msymbols (char *args, int from_tty)
        || compare_filenames_for_search (objfile_name (objfile), objfile_arg))
       dump_msymbols (objfile, outfile);
   }
-
-  do_cleanups (cleanups);
 }
 
 static void
This page took 0.039572 seconds and 4 git commands to generate.