}
/* Set the filename. */
- void set_name (const char *name)
+ void set_name (gdb::unique_xmalloc_ptr<char> name)
{
- m_name = name;
+ m_name_storage = std::move (name);
+ m_name = m_name_storage.get ();
}
private:
/* The filename. */
const char *m_name;
+ /* Storage for the filename, if needed. */
+ gdb::unique_xmalloc_ptr<char> m_name_storage;
+
/* The compilation directory. NULL if not known. If we needed to
compute a new string, it will be stored in the comp_dir_storage
member, and this will be NULL. Otherwise, points directly to the
prepare_one_comp_unit (cu, comp_unit_die, pretend_language);
/* Allocate a new partial symbol table structure. */
- gdb::unique_xmalloc_ptr<char> debug_filename;
static const char artificial[] = "<artificial>";
file_and_directory &fnd = find_file_and_directory (comp_unit_die, cu);
if (strcmp (fnd.get_name (), artificial) == 0)
{
- debug_filename.reset (concat (artificial, "@",
- sect_offset_str (per_cu->sect_off),
- (char *) NULL));
- fnd.set_name (debug_filename.get ());
+ gdb::unique_xmalloc_ptr<char> debug_filename
+ (concat (artificial, "@",
+ sect_offset_str (per_cu->sect_off),
+ (char *) NULL));
+ fnd.set_name (std::move (debug_filename));
}
pst = create_partial_symtab (per_cu, per_objfile, fnd.get_name ());