From e3e41d588adbe26a6ca54338dd4915382d981a3e Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Thu, 3 Aug 2017 16:32:14 -0600 Subject: Change gdb_abspath to return a unique_xmalloc_ptr This changes gdb_abspath to return a unique_xmalloc_ptr, and fixes up the callers. This allows the removal of a cleanup, and also puts ownership rules into the API, where they belong. ChangeLog 2017-08-22 Tom Tromey * compile/compile.c (compile_file_command): Use gdb::unique_xmalloc_ptr, std::string. * utils.c (gdb_abspath): Change return type. * source.c (openp): Update. * objfiles.c (allocate_objfile): Update. * main.c (set_gdb_data_directory): Update. * utils.h (gdb_abspath): Return a gdb::unique_xmalloc_ptr. --- gdb/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gdb/main.c') diff --git a/gdb/main.c b/gdb/main.c index 9813041..886e17f 100644 --- a/gdb/main.c +++ b/gdb/main.c @@ -128,10 +128,10 @@ set_gdb_data_directory (const char *new_datadir) isn't canonical, but that's ok. */ if (!IS_ABSOLUTE_PATH (gdb_datadir)) { - char *abs_datadir = gdb_abspath (gdb_datadir); + gdb::unique_xmalloc_ptr abs_datadir = gdb_abspath (gdb_datadir); xfree (gdb_datadir); - gdb_datadir = abs_datadir; + gdb_datadir = abs_datadir.release (); } } -- cgit v1.1