diff options
author | Tom Tromey <tom@tromey.com> | 2017-08-03 16:32:14 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2017-08-22 09:30:10 -0600 |
commit | e3e41d588adbe26a6ca54338dd4915382d981a3e (patch) | |
tree | 82e4563027b5e460a017465c39ec252257fb591d /gdb/objfiles.c | |
parent | 0d999a6ef0f98b22430d70951408869864c979e0 (diff) | |
download | gdb-e3e41d588adbe26a6ca54338dd4915382d981a3e.zip gdb-e3e41d588adbe26a6ca54338dd4915382d981a3e.tar.gz gdb-e3e41d588adbe26a6ca54338dd4915382d981a3e.tar.bz2 |
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 <tom@tromey.com>
* 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.
Diffstat (limited to 'gdb/objfiles.c')
-rw-r--r-- | gdb/objfiles.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/gdb/objfiles.c b/gdb/objfiles.c index d261c87..ff99ca6 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -386,22 +386,25 @@ allocate_objfile (bfd *abfd, const char *name, objfile_flags flags) objfile_alloc_data (objfile); + gdb::unique_xmalloc_ptr<char> name_holder; if (name == NULL) { gdb_assert (abfd == NULL); gdb_assert ((flags & OBJF_NOT_FILENAME) != 0); - expanded_name = xstrdup ("<<anonymous objfile>>"); + expanded_name = "<<anonymous objfile>>"; } else if ((flags & OBJF_NOT_FILENAME) != 0 || is_target_filename (name)) - expanded_name = xstrdup (name); + expanded_name = name; else - expanded_name = gdb_abspath (name); + { + name_holder = gdb_abspath (name); + expanded_name = name_holder.get (); + } objfile->original_name = (char *) obstack_copy0 (&objfile->objfile_obstack, expanded_name, strlen (expanded_name)); - xfree (expanded_name); /* Update the per-objfile information that comes from the bfd, ensuring that any data that is reference is saved in the per-objfile data |