diff options
author | Tom Tromey <tom@tromey.com> | 2016-11-20 13:20:32 -0700 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2017-01-10 19:14:08 -0700 |
commit | fc4007c969ec4208fb7c7cee2f50211a9aa0f40f (patch) | |
tree | 124c95351da6ad220406cd45875c72043259440d /gdb/linespec.c | |
parent | 8dbcee674ea4a8daa55f880ad7ade96efca96951 (diff) | |
download | gdb-fc4007c969ec4208fb7c7cee2f50211a9aa0f40f.zip gdb-fc4007c969ec4208fb7c7cee2f50211a9aa0f40f.tar.gz gdb-fc4007c969ec4208fb7c7cee2f50211a9aa0f40f.tar.bz2 |
Remove make_cleanup_htab_delete
This removes make_cleanup_htab_delete in favor of destructors,
building on an earlier patch that added the htab_up typedef.
Testing revealed that more cleanup-removal work was needed in
dwarf2loc.c, so this version of the patch changes code there to use
unordered_set and vector, removing some more cleanups.
2017-01-10 Tom Tromey <tom@tromey.com>
* utils.h (make_cleanup_htab_delete): Don't declare.
* utils.c (do_htab_delete_cleanup, make_cleanup_htab_delete):
Remove.
* linespec.c (decode_compound_collector): Add constructor,
destructor.
(lookup_prefix_sym): Remove cleanup.
(symtab_collector): Add constructor, destructor.
(collect_symtabs_from_filename): Remove cleanup.
* disasm.c (do_mixed_source_and_assembly): Use htab_up.
* compile/compile-c-symbols.c (generate_c_for_variable_locations):
Use htab_up.
* gnu-v3-abi.c (gnuv3_print_vtable): Use htab_up.
* dwarf2read.c (dw2_expand_symtabs_matching)
(dw2_map_symbol_filenames, dwarf_decode_macros)
(write_psymtabs_to_index): Use htab_up.
* dwarf2loc.c (func_verify_no_selftailcall)
(call_site_find_chain_1, func_verify_no_selftailcall)
(chain_candidate, call_site_find_chain_1): Use std::unordered_set,
std::vector, gdb::unique_xmalloc_ptr.
(call_sitep): Remove typedef.
(dwarf2_locexpr_baton_eval): Remove unused variable.
Diffstat (limited to 'gdb/linespec.c')
-rw-r--r-- | gdb/linespec.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/gdb/linespec.c b/gdb/linespec.c index a538de7..6308026 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -2835,6 +2835,18 @@ struct decode_compound_collector /* A hash table of all symbols we found. We use this to avoid adding any symbol more than once. */ htab_t unique_syms; + + decode_compound_collector () + : symbols (NULL), + unique_syms (NULL) + { + } + + ~decode_compound_collector () + { + if (unique_syms != NULL) + htab_delete (unique_syms); + } }; /* A callback for iterate_over_symbols that is used by @@ -2886,7 +2898,6 @@ lookup_prefix_sym (struct linespec_state *state, VEC (symtab_ptr) *file_symtabs, collector.unique_syms = htab_create_alloc (1, htab_hash_pointer, htab_eq_pointer, NULL, xcalloc, xfree); - cleanup = make_cleanup_htab_delete (collector.unique_syms); for (ix = 0; VEC_iterate (symtab_ptr, file_symtabs, ix, elt); ++ix) { @@ -2912,7 +2923,6 @@ lookup_prefix_sym (struct linespec_state *state, VEC (symtab_ptr) *file_symtabs, } } - do_cleanups (cleanup); discard_cleanups (outer); return collector.symbols; } @@ -3129,6 +3139,18 @@ struct symtab_collector /* This is used to ensure the symtabs are unique. */ htab_t symtab_table; + + symtab_collector () + : symtabs (NULL), + symtab_table (NULL) + { + } + + ~symtab_collector () + { + if (symtab_table != NULL) + htab_delete (symtab_table); + } }; /* Callback for iterate_over_symtabs. */ @@ -3164,7 +3186,6 @@ collect_symtabs_from_filename (const char *file, collector.symtabs = NULL; collector.symtab_table = htab_create (1, htab_hash_pointer, htab_eq_pointer, NULL); - cleanups = make_cleanup_htab_delete (collector.symtab_table); /* Find that file's data. */ if (search_pspace == NULL) @@ -3184,7 +3205,6 @@ collect_symtabs_from_filename (const char *file, iterate_over_symtabs (file, add_symtabs_to_list, &collector); } - do_cleanups (cleanups); return collector.symtabs; } |