This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA] 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.

2016-11-20  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): Use htab_up.
---
 gdb/ChangeLog                   | 20 +++++++++++
 gdb/compile/compile-c-symbols.c | 11 +++---
 gdb/disasm.c                    | 14 +++-----
 gdb/dwarf2loc.c                 | 33 ++++++++---------
 gdb/dwarf2read.c                | 79 +++++++++++++++++------------------------
 gdb/gnu-v3-abi.c                | 12 +++----
 gdb/linespec.c                  | 28 ++++++++++++---
 gdb/utils.c                     | 18 ----------
 gdb/utils.h                     |  2 --
 9 files changed, 105 insertions(+), 112 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index c6edec2..dde3e49 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,25 @@
 2016-11-20  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): Use htab_up.
+
+2016-11-20  Tom Tromey  <tom@tromey.com>
+
 	* python/python-internal.h (make_cleanup_py_decref)
 	(make_cleanup_py_xdecref): Don't declare.
 	* python/py-utils.c (py_decref, make_cleanup_py_decref)
diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c
index dcd530d..012fded 100644
--- a/gdb/compile/compile-c-symbols.c
+++ b/gdb/compile/compile-c-symbols.c
@@ -724,8 +724,7 @@ generate_c_for_variable_locations (struct compile_c_instance *compiler,
 				   const struct block *block,
 				   CORE_ADDR pc)
 {
-  struct cleanup *cleanup, *outer;
-  htab_t symhash;
+  struct cleanup *outer;
   const struct block *static_block = block_static_block (block);
   unsigned char *registers_used;
 
@@ -739,9 +738,8 @@ generate_c_for_variable_locations (struct compile_c_instance *compiler,
 
   /* Ensure that a given name is only entered once.  This reflects the
      reality of shadowing.  */
-  symhash = htab_create_alloc (1, hash_symname, eq_symname, NULL,
-			       xcalloc, xfree);
-  cleanup = make_cleanup_htab_delete (symhash);
+  htab_up symhash (htab_create_alloc (1, hash_symname, eq_symname, NULL,
+				      xcalloc, xfree));
 
   while (1)
     {
@@ -754,7 +752,7 @@ generate_c_for_variable_locations (struct compile_c_instance *compiler,
 	   sym != NULL;
 	   sym = block_iterator_next (&iter))
 	{
-	  if (!symbol_seen (symhash, sym))
+	  if (!symbol_seen (symhash.get (), sym))
 	    generate_c_for_for_one_variable (compiler, stream, gdbarch,
 					     registers_used, pc, sym);
 	}
@@ -766,7 +764,6 @@ generate_c_for_variable_locations (struct compile_c_instance *compiler,
       block = BLOCK_SUPERBLOCK (block);
     }
 
-  do_cleanups (cleanup);
   discard_cleanups (outer);
   return registers_used;
 }
diff --git a/gdb/disasm.c b/gdb/disasm.c
index 07c3abe..3156a4e 100644
--- a/gdb/disasm.c
+++ b/gdb/disasm.c
@@ -498,14 +498,12 @@ do_mixed_source_and_assembly (struct gdbarch *gdbarch, struct ui_out *uiout,
   int i, nlines;
   int num_displayed = 0;
   print_source_lines_flags psl_flags = 0;
-  struct cleanup *cleanups;
   struct cleanup *ui_out_chain;
   struct cleanup *ui_out_tuple_chain;
   struct cleanup *ui_out_list_chain;
   CORE_ADDR pc;
   struct symtab *last_symtab;
   int last_line;
-  htab_t dis_line_table;
 
   gdb_assert (main_symtab != NULL && SYMTAB_LINETABLE (main_symtab) != NULL);
 
@@ -515,8 +513,7 @@ do_mixed_source_and_assembly (struct gdbarch *gdbarch, struct ui_out *uiout,
      but if that text is for code that will be disassembled later, then
      we'll want to defer printing it until later with its associated code.  */
 
-  dis_line_table = allocate_dis_line_table ();
-  cleanups = make_cleanup_htab_delete (dis_line_table);
+  htab_up dis_line_table (allocate_dis_line_table ());
 
   pc = low;
 
@@ -548,7 +545,7 @@ do_mixed_source_and_assembly (struct gdbarch *gdbarch, struct ui_out *uiout,
       pc += length;
 
       if (sal.symtab != NULL)
-	add_dis_line_entry (dis_line_table, sal.symtab, sal.line);
+	add_dis_line_entry (dis_line_table.get (), sal.symtab, sal.line);
     }
 
   /* Second pass: print the disassembly.
@@ -565,9 +562,6 @@ do_mixed_source_and_assembly (struct gdbarch *gdbarch, struct ui_out *uiout,
      which is where we put file name and source line contents output.
 
      Cleanup usage:
-     cleanups:
-       For things created at the beginning of this function and need to be
-       kept until the end of this function.
      ui_out_chain
        Handles the outer "asm_insns" list.
      ui_out_tuple_chain
@@ -625,7 +619,8 @@ do_mixed_source_and_assembly (struct gdbarch *gdbarch, struct ui_out *uiout,
 		     not associated with code that we'll print later.  */
 		  for (l = sal.line - 1; l > last_line; --l)
 		    {
-		      if (line_has_code_p (dis_line_table, sal.symtab, l))
+		      if (line_has_code_p (dis_line_table.get (),
+					   sal.symtab, l))
 			break;
 		    }
 		  if (l < sal.line - 1)
@@ -729,7 +724,6 @@ do_mixed_source_and_assembly (struct gdbarch *gdbarch, struct ui_out *uiout,
     }
 
   do_cleanups (ui_out_chain);
-  do_cleanups (cleanups);
 }
 
 static void
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index 44dceda..2a71d1e 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -792,19 +792,17 @@ func_verify_no_selftailcall (struct gdbarch *gdbarch, CORE_ADDR verify_addr)
   struct cleanup *old_chain;
   CORE_ADDR addr;
 
-  /* Track here CORE_ADDRs which were already visited.  */
-  htab_t addr_hash;
-
   /* The verification is completely unordered.  Track here function addresses
      which still need to be iterated.  */
   VEC (CORE_ADDR) *todo = NULL;
 
   obstack_init (&addr_obstack);
   old_chain = make_cleanup_obstack_free (&addr_obstack);   
-  addr_hash = htab_create_alloc_ex (64, core_addr_hash, core_addr_eq, NULL,
-				    &addr_obstack, hashtab_obstack_allocate,
-				    NULL);
-  make_cleanup_htab_delete (addr_hash);
+
+  /* Track here CORE_ADDRs which were already visited.  */
+  htab_up addr_hash (htab_create_alloc_ex (64, core_addr_hash, core_addr_eq,
+					   NULL, &addr_obstack,
+					   hashtab_obstack_allocate, NULL));
 
   make_cleanup (VEC_cleanup (CORE_ADDR), &todo);
 
@@ -842,7 +840,7 @@ func_verify_no_selftailcall (struct gdbarch *gdbarch, CORE_ADDR verify_addr)
 			   paddress (gdbarch, verify_addr));
 	    }
 
-	  slot = htab_find_slot (addr_hash, &target_addr, INSERT);
+	  slot = htab_find_slot (addr_hash.get (), &target_addr, INSERT);
 	  if (*slot == NULL)
 	    {
 	      *slot = obstack_copy (&addr_obstack, &target_addr,
@@ -991,9 +989,6 @@ call_site_find_chain_1 (struct gdbarch *gdbarch, CORE_ADDR caller_pc,
   struct call_site_chain *retval = NULL;
   struct call_site *call_site;
 
-  /* Mark CALL_SITEs so we do not visit the same ones twice.  */
-  htab_t addr_hash;
-
   /* CHAIN contains only the intermediate CALL_SITEs.  Neither CALLER_PC's
      call_site nor any possible call_site at CALLEE_PC's function is there.
      Any CALL_SITE in CHAIN will be iterated to its siblings - via
@@ -1010,10 +1005,11 @@ call_site_find_chain_1 (struct gdbarch *gdbarch, CORE_ADDR caller_pc,
 
   obstack_init (&addr_obstack);
   back_to_workdata = make_cleanup_obstack_free (&addr_obstack);   
-  addr_hash = htab_create_alloc_ex (64, core_addr_hash, core_addr_eq, NULL,
-				    &addr_obstack, hashtab_obstack_allocate,
-				    NULL);
-  make_cleanup_htab_delete (addr_hash);
+
+  /* Mark CALL_SITEs so we do not visit the same ones twice.  */
+  htab_up addr_hash (htab_create_alloc_ex (64, core_addr_hash, core_addr_eq,
+					   NULL, &addr_obstack,
+					   hashtab_obstack_allocate, NULL));
 
   make_cleanup (VEC_cleanup (call_sitep), &chain);
 
@@ -1058,7 +1054,8 @@ call_site_find_chain_1 (struct gdbarch *gdbarch, CORE_ADDR caller_pc,
 	    {
 	      void **slot;
 
-	      slot = htab_find_slot (addr_hash, &target_call_site->pc, INSERT);
+	      slot = htab_find_slot (addr_hash.get (), &target_call_site->pc,
+				     INSERT);
 	      if (*slot == NULL)
 		{
 		  /* Successfully entered TARGET_CALL_SITE.  */
@@ -1078,9 +1075,9 @@ call_site_find_chain_1 (struct gdbarch *gdbarch, CORE_ADDR caller_pc,
 	    {
 	      call_site = VEC_pop (call_sitep, chain);
 
-	      gdb_assert (htab_find_slot (addr_hash, &call_site->pc,
+	      gdb_assert (htab_find_slot (addr_hash.get (), &call_site->pc,
 					  NO_INSERT) != NULL);
-	      htab_remove_elt (addr_hash, &call_site->pc);
+	      htab_remove_elt (addr_hash.get (), &call_site->pc);
 
 	      target_call_site = call_site->tail_call_next;
 	      if (target_call_site)
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 1ad6b00..6021404 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -3894,17 +3894,12 @@ dw2_expand_symtabs_matching
 
   if (file_matcher != NULL)
     {
-      struct cleanup *cleanup;
-      htab_t visited_found, visited_not_found;
-
-      visited_found = htab_create_alloc (10,
-					 htab_hash_pointer, htab_eq_pointer,
-					 NULL, xcalloc, xfree);
-      cleanup = make_cleanup_htab_delete (visited_found);
-      visited_not_found = htab_create_alloc (10,
-					     htab_hash_pointer, htab_eq_pointer,
-					     NULL, xcalloc, xfree);
-      make_cleanup_htab_delete (visited_not_found);
+      htab_up visited_found (htab_create_alloc (10, htab_hash_pointer,
+						htab_eq_pointer,
+						NULL, xcalloc, xfree));
+      htab_up visited_not_found (htab_create_alloc (10, htab_hash_pointer,
+						    htab_eq_pointer,
+						    NULL, xcalloc, xfree));
 
       /* The rule is CUs specify all the files, including those used by
 	 any TU, so there's no need to scan TUs here.  */
@@ -3928,9 +3923,9 @@ dw2_expand_symtabs_matching
 	  if (file_data == NULL)
 	    continue;
 
-	  if (htab_find (visited_not_found, file_data) != NULL)
+	  if (htab_find (visited_not_found.get (), file_data) != NULL)
 	    continue;
-	  else if (htab_find (visited_found, file_data) != NULL)
+	  else if (htab_find (visited_found.get (), file_data) != NULL)
 	    {
 	      per_cu->v.quick->mark = 1;
 	      continue;
@@ -3962,13 +3957,11 @@ dw2_expand_symtabs_matching
 	    }
 
 	  slot = htab_find_slot (per_cu->v.quick->mark
-				 ? visited_found
-				 : visited_not_found,
+				 ? visited_found.get ()
+				 : visited_not_found.get (),
 				 file_data, INSERT);
 	  *slot = file_data;
 	}
-
-      do_cleanups (cleanup);
     }
 
   for (iter = 0; iter < index->symbol_table_slots; ++iter)
@@ -4135,11 +4128,9 @@ dw2_map_symbol_filenames (struct objfile *objfile, symbol_filename_ftype *fun,
 			  void *data, int need_fullname)
 {
   int i;
-  struct cleanup *cleanup;
-  htab_t visited = htab_create_alloc (10, htab_hash_pointer, htab_eq_pointer,
-				      NULL, xcalloc, xfree);
+  htab_up visited (htab_create_alloc (10, htab_hash_pointer, htab_eq_pointer,
+				      NULL, xcalloc, xfree));
 
-  cleanup = make_cleanup_htab_delete (visited);
   dw2_setup (objfile);
 
   /* The rule is CUs specify all the files, including those used by
@@ -4152,7 +4143,8 @@ dw2_map_symbol_filenames (struct objfile *objfile, symbol_filename_ftype *fun,
 
       if (per_cu->v.quick->compunit_symtab)
 	{
-	  void **slot = htab_find_slot (visited, per_cu->v.quick->file_names,
+	  void **slot = htab_find_slot (visited.get (),
+					per_cu->v.quick->file_names,
 					INSERT);
 
 	  *slot = per_cu->v.quick->file_names;
@@ -4174,7 +4166,7 @@ dw2_map_symbol_filenames (struct objfile *objfile, symbol_filename_ftype *fun,
       if (file_data == NULL)
 	continue;
 
-      slot = htab_find_slot (visited, file_data, INSERT);
+      slot = htab_find_slot (visited.get (), file_data, INSERT);
       if (*slot)
 	{
 	  /* Already visited.  */
@@ -4193,8 +4185,6 @@ dw2_map_symbol_filenames (struct objfile *objfile, symbol_filename_ftype *fun,
 	  (*fun) (file_data->file_names[j], this_real_name, data);
 	}
     }
-
-  do_cleanups (cleanup);
 }
 
 static int
@@ -21570,7 +21560,6 @@ dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset,
   unsigned int offset_size = cu->header.offset_size;
   const gdb_byte *opcode_definitions[256];
   struct cleanup *cleanup;
-  htab_t include_hash;
   void **slot;
   struct dwarf2_section_info *section;
   const char *section_name;
@@ -21736,16 +21725,16 @@ dwarf_decode_macros (struct dwarf2_cu *cu, unsigned int offset,
      command-line macro definitions/undefinitions.  This flag is unset when we
      reach the first DW_MACINFO_start_file entry.  */
 
-  include_hash = htab_create_alloc (1, htab_hash_pointer, htab_eq_pointer,
-				    NULL, xcalloc, xfree);
-  cleanup = make_cleanup_htab_delete (include_hash);
+  htab_up include_hash (htab_create_alloc (1, htab_hash_pointer,
+					   htab_eq_pointer,
+					   NULL, xcalloc, xfree));
   mac_ptr = section->buffer + offset;
-  slot = htab_find_slot (include_hash, mac_ptr, INSERT);
+  slot = htab_find_slot (include_hash.get (), mac_ptr, INSERT);
   *slot = (void *) mac_ptr;
   dwarf_decode_macro_bytes (abfd, mac_ptr, mac_end,
 			    current_file, lh, section,
-			    section_is_gnu, 0, offset_size, include_hash);
-  do_cleanups (cleanup);
+			    section_is_gnu, 0, offset_size,
+			    include_hash.get ());
 }
 
 /* Check if the attribute's form is a DW_FORM_block*
@@ -23274,8 +23263,6 @@ write_psymtabs_to_index (struct objfile *objfile, const char *dir)
   struct mapped_symtab *symtab;
   offset_type val, size_of_contents, total_len;
   struct stat st;
-  htab_t psyms_seen;
-  htab_t cu_index_htab;
   struct psymtab_cu_index_map *psymtab_cu_index_map;
 
   if (dwarf2_per_objfile->using_index)
@@ -23313,19 +23300,18 @@ write_psymtabs_to_index (struct objfile *objfile, const char *dir)
   obstack_init (&types_cu_list);
   make_cleanup_obstack_free (&types_cu_list);
 
-  psyms_seen = htab_create_alloc (100, htab_hash_pointer, htab_eq_pointer,
-				  NULL, xcalloc, xfree);
-  make_cleanup_htab_delete (psyms_seen);
+  htab_up psyms_seen (htab_create_alloc (100, htab_hash_pointer,
+					 htab_eq_pointer,
+					 NULL, xcalloc, xfree));
 
   /* While we're scanning CU's create a table that maps a psymtab pointer
      (which is what addrmap records) to its index (which is what is recorded
      in the index file).  This will later be needed to write the address
      table.  */
-  cu_index_htab = htab_create_alloc (100,
-				     hash_psymtab_cu_index,
-				     eq_psymtab_cu_index,
-				     NULL, xcalloc, xfree);
-  make_cleanup_htab_delete (cu_index_htab);
+  htab_up cu_index_htab (htab_create_alloc (100,
+					    hash_psymtab_cu_index,
+					    eq_psymtab_cu_index,
+					    NULL, xcalloc, xfree));
   psymtab_cu_index_map = XNEWVEC (struct psymtab_cu_index_map,
 				  dwarf2_per_objfile->n_comp_units);
   make_cleanup (xfree, psymtab_cu_index_map);
@@ -23349,12 +23335,13 @@ write_psymtabs_to_index (struct objfile *objfile, const char *dir)
 	continue;
 
       if (psymtab->user == NULL)
-	recursively_write_psymbols (objfile, psymtab, symtab, psyms_seen, i);
+	recursively_write_psymbols (objfile, psymtab, symtab,
+				    psyms_seen.get (), i);
 
       map = &psymtab_cu_index_map[i];
       map->psymtab = psymtab;
       map->cu_index = i;
-      slot = htab_find_slot (cu_index_htab, map, INSERT);
+      slot = htab_find_slot (cu_index_htab.get (), map, INSERT);
       gdb_assert (slot != NULL);
       gdb_assert (*slot == NULL);
       *slot = map;
@@ -23367,7 +23354,7 @@ write_psymtabs_to_index (struct objfile *objfile, const char *dir)
     }
 
   /* Dump the address map.  */
-  write_address_map (objfile, &addr_obstack, cu_index_htab);
+  write_address_map (objfile, &addr_obstack, cu_index_htab.get ());
 
   /* Write out the .debug_type entries, if any.  */
   if (dwarf2_per_objfile->signatured_types)
@@ -23377,7 +23364,7 @@ write_psymtabs_to_index (struct objfile *objfile, const char *dir)
       sig_data.objfile = objfile;
       sig_data.symtab = symtab;
       sig_data.types_list = &types_cu_list;
-      sig_data.psyms_seen = psyms_seen;
+      sig_data.psyms_seen = psyms_seen.get ();
       sig_data.cu_index = dwarf2_per_objfile->n_comp_units;
       htab_traverse_noresize (dwarf2_per_objfile->signatured_types,
 			      write_one_signatured_type, &sig_data);
diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c
index 9be9cd9..c4f0f8f 100644
--- a/gdb/gnu-v3-abi.c
+++ b/gdb/gnu-v3-abi.c
@@ -940,7 +940,6 @@ gnuv3_print_vtable (struct value *value)
   struct type *type;
   struct value *vtable;
   struct value_print_options opts;
-  htab_t offset_hash;
   struct cleanup *cleanup;
   VEC (value_and_voffset_p) *result_vec = NULL;
   struct value_and_voffset *iter;
@@ -976,13 +975,12 @@ gnuv3_print_vtable (struct value *value)
       return;
     }
 
-  offset_hash = htab_create_alloc (1, hash_value_and_voffset,
-				   eq_value_and_voffset,
-				   xfree, xcalloc, xfree);
-  cleanup = make_cleanup_htab_delete (offset_hash);
-  make_cleanup (VEC_cleanup (value_and_voffset_p), &result_vec);
+  htab_up offset_hash (htab_create_alloc (1, hash_value_and_voffset,
+					  eq_value_and_voffset,
+					  xfree, xcalloc, xfree));
+  cleanup = make_cleanup (VEC_cleanup (value_and_voffset_p), &result_vec);
 
-  compute_vtable_size (offset_hash, &result_vec, value);
+  compute_vtable_size (offset_hash.get (), &result_vec, value);
 
   qsort (VEC_address (value_and_voffset_p, result_vec),
 	 VEC_length (value_and_voffset_p, result_vec),
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 1604267..7694635 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;
 }
 
diff --git a/gdb/utils.c b/gdb/utils.c
index 751f099..94dab2a 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -301,24 +301,6 @@ make_cleanup_unpush_target (struct target_ops *ops)
   return make_cleanup (do_unpush_target, ops);
 }
 
-/* Helper for make_cleanup_htab_delete compile time checking the types.  */
-
-static void
-do_htab_delete_cleanup (void *htab_voidp)
-{
-  htab_t htab = (htab_t) htab_voidp;
-
-  htab_delete (htab);
-}
-
-/* Return a new cleanup that deletes HTAB.  */
-
-struct cleanup *
-make_cleanup_htab_delete (htab_t htab)
-{
-  return make_cleanup (do_htab_delete_cleanup, htab);
-}
-
 /* Helper for make_cleanup_value_free_to_mark.  */
 
 static void
diff --git a/gdb/utils.h b/gdb/utils.h
index a1692c6..49be7c9 100644
--- a/gdb/utils.h
+++ b/gdb/utils.h
@@ -111,8 +111,6 @@ struct htab_deleter
 /* A unique_ptr wrapper for htab_t.  */
 typedef std::unique_ptr<htab, htab_deleter> htab_up;
 
-extern struct cleanup *make_cleanup_htab_delete (htab_t htab);
-
 struct parser_state;
 extern struct cleanup *make_cleanup_clear_parser_state
   (struct parser_state **p);
-- 
2.7.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]