Use gdb::unique_xmalloc_ptr when calling tilde_expand
[deliverable/binutils-gdb.git] / gdb / psymtab.c
index a3762b54498b310aee873efd80f0439d190694dc..8283545f9ea09850926fd81dee26df2f5bfdc157 100644 (file)
@@ -1906,7 +1906,6 @@ static void
 maintenance_print_psymbols (char *args, int from_tty)
 {
   struct ui_file *outfile = gdb_stdout;
-  struct cleanup *cleanups;
   char *address_arg = NULL, *source_arg = NULL, *objfile_arg = NULL;
   struct objfile *objfile;
   struct partial_symtab *ps;
@@ -1917,7 +1916,6 @@ maintenance_print_psymbols (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)
     {
@@ -1962,14 +1960,12 @@ maintenance_print_psymbols (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;
     }
 
@@ -2060,8 +2056,6 @@ maintenance_print_psymbols (char *args, int from_tty)
       if (source_arg != NULL)
        error (_("No partial symtab for source file: %s"), source_arg);
     }
-
-  do_cleanups (cleanups);
 }
 
 /* List all the partial symbol tables whose names match REGEXP (optional).  */
This page took 0.025288 seconds and 4 git commands to generate.