Use unique_xmalloc_ptr in jit.c
authorTom Tromey <tom@tromey.com>
Sat, 29 Apr 2017 05:08:16 +0000 (23:08 -0600)
committerTom Tromey <tom@tromey.com>
Thu, 3 Aug 2017 13:59:01 +0000 (07:59 -0600)
This removes some cleanups from jit.c by using unique_xmalloc_ptr
instead.

ChangeLog
2017-08-03  Tom Tromey  <tom@tromey.com>

* jit.c (jit_reader_load_command): Use unique_xmalloc_ptr.

gdb/ChangeLog
gdb/jit.c

index c13045865b146112173c3c4737346e3e7a39a434..56fc66199f20d4786ac9010e4750b6bb440dda13 100644 (file)
@@ -1,3 +1,7 @@
+2017-08-03  Tom Tromey  <tom@tromey.com>
+
+       * jit.c (jit_reader_load_command): Use unique_xmalloc_ptr.
+
 2017-08-03  Tom Tromey  <tom@tromey.com>
 
        * tui/tui-regs.c (tui_restore_gdbout): Remove.
index ddf1005b649414b85dde47a4a4494603c3d945cd..725d41ef0a5b01a22d5994bdd4b7b336fd3c10a9 100644 (file)
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -211,29 +211,20 @@ jit_reader_load (const char *file_name)
 static void
 jit_reader_load_command (char *args, int from_tty)
 {
-  char *so_name;
-  struct cleanup *prev_cleanup;
-
   if (args == NULL)
     error (_("No reader name provided."));
-  args = tilde_expand (args);
-  prev_cleanup = make_cleanup (xfree, args);
+  gdb::unique_xmalloc_ptr<char> file (tilde_expand (args));
 
   if (loaded_jit_reader != NULL)
     error (_("JIT reader already loaded.  Run jit-reader-unload first."));
 
-  if (IS_ABSOLUTE_PATH (args))
-    so_name = args;
-  else
-    {
-      so_name = xstrprintf ("%s%s%s", jit_reader_dir, SLASH_STRING, args);
-      make_cleanup (xfree, so_name);
-    }
+  if (!IS_ABSOLUTE_PATH (file.get ()))
+    file.reset (xstrprintf ("%s%s%s", jit_reader_dir, SLASH_STRING,
+                           file.get ()));
 
-  loaded_jit_reader = jit_reader_load (so_name);
+  loaded_jit_reader = jit_reader_load (file.get ());
   reinit_frame_cache ();
   jit_inferior_created_hook ();
-  do_cleanups (prev_cleanup);
 }
 
 /* Provides the jit-reader-unload command.  */
This page took 0.029478 seconds and 4 git commands to generate.