2018-07-16 Tom Tromey <tom@tromey.com>
+ * buildsym.c (~buildsym_compunit): Update.
+ (struct buildsym_compunit) <comp_unit>: Now a unique_xmalloc_ptr.
+ (start_subfile, patch_subfile_names)
+ (end_symtab_with_blockvector): Update.
+
+2018-07-16 Tom Tromey <tom@tromey.com>
+
* buildsym.c (struct buildsym_compunit): Add constructor,
destructor, initializers.
(start_buildsym_compunit): Remove.
xfree (subfile->line_vector);
xfree (subfile);
}
- xfree (comp_dir);
}
/* The objfile we're reading debug info from. */
struct subfile *main_subfile = nullptr;
/* E.g., DW_AT_comp_dir if DWARF. Space for this is malloc'd. */
- char *comp_dir;
+ gdb::unique_xmalloc_ptr<char> comp_dir;
/* Space for this is not malloc'd, and is assumed to have at least
the same lifetime as objfile. */
gdb_assert (buildsym_compunit != NULL);
- subfile_dirname = buildsym_compunit->comp_dir;
+ subfile_dirname = buildsym_compunit->comp_dir.get ();
/* See if this subfile is already registered. */
&& subfile->name != NULL
&& IS_DIR_SEPARATOR (subfile->name[strlen (subfile->name) - 1]))
{
- buildsym_compunit->comp_dir = subfile->name;
+ buildsym_compunit->comp_dir.reset (subfile->name);
subfile->name = xstrdup (name);
set_last_source_file (name);
if (buildsym_compunit->comp_dir != NULL)
{
/* Reallocate the dirname on the symbol obstack. */
+ const char *comp_dir = buildsym_compunit->comp_dir.get ();
COMPUNIT_DIRNAME (cu)
= (const char *) obstack_copy0 (&objfile->objfile_obstack,
- buildsym_compunit->comp_dir,
- strlen (buildsym_compunit->comp_dir));
+ comp_dir, strlen (comp_dir));
}
/* Save the debug format string (if any) in the symtab. */