From e39db4db7c553ae1c4aaf158cd0ebf3cf6d478fb Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Sun, 20 May 2018 21:07:03 -0400 Subject: Use XOBNEW/XOBNEWVEC/OBSTACK_ZALLOC when possible Since XOBNEW/XOBNEWVEC/OBSTACK_ZALLOC are now poisoned to prevent using them with non-trivially-constructible objects, it is worth using them over plain obstack_alloc. This patch changes the locations I could find where we can do that change easily. gdb/ChangeLog: * ada-lang.c (cache_symbol): Use XOBNEW and/or XOBNEWVEC and/or OBSTACK_ZALLOC. * dwarf2-frame.c (dwarf2_build_frame_info): Likewise. * hppa-tdep.c (hppa_init_objfile_priv_data): Likewise. * mdebugread.c (mdebug_build_psymtabs): Likewise. (add_pending): Likewise. (parse_symbol): Likewise. (parse_partial_symbols): Likewise. (psymtab_to_symtab_1): Likewise. (new_psymtab): Likewise. (elfmdebug_build_psymtabs): Likewise. * minsyms.c (terminate_minimal_symbol_table): Likewise. * objfiles.c (get_objfile_bfd_data): Likewise. (objfile_register_static_link): Likewise. * psymtab.c (allocate_psymtab): Likewise. * stabsread.c (read_member_functions): Likewise. * xcoffread.c (xcoff_end_psymtab): Likewise. --- gdb/objfiles.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'gdb/objfiles.c') diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 98e81c4..2ec358a 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -147,11 +147,7 @@ get_objfile_bfd_data (struct objfile *objfile, struct bfd *abfd) set_bfd_data (abfd, objfiles_bfd_data, storage); } else - { - storage = (objfile_per_bfd_storage *) - obstack_alloc (&objfile->objfile_obstack, - sizeof (objfile_per_bfd_storage)); - } + storage = XOBNEW (&objfile->objfile_obstack, objfile_per_bfd_storage); /* objfile_per_bfd_storage is not trivially constructible, must call the ctor manually. */ @@ -269,8 +265,7 @@ objfile_register_static_link (struct objfile *objfile, slot = htab_find_slot (objfile->static_links, &lookup_entry, INSERT); gdb_assert (*slot == NULL); - entry = (struct static_link_htab_entry *) obstack_alloc - (&objfile->objfile_obstack, sizeof (*entry)); + entry = XOBNEW (&objfile->objfile_obstack, static_link_htab_entry); entry->block = block; entry->static_link = static_link; *slot = (void *) entry; -- cgit v1.1