]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Make objfile::static_links an htab_up
authorTom Tromey <tom@tromey.com>
Sun, 7 Apr 2019 21:39:37 +0000 (15:39 -0600)
committerTom Tromey <tom@tromey.com>
Fri, 19 Apr 2019 20:20:25 +0000 (14:20 -0600)
This changes objfile::static_links to be an htab_up, so that ~objfile
no longer has to explicitly destroy it.

Tested by the buildbot.

gdb/ChangeLog
2019-04-19  Tom Tromey  <tom@tromey.com>

* symfile.c (reread_symbols): Update.
* objfiles.c (objfile_register_static_link)
(objfile_lookup_static_link): Update
(~objfile) Don't delete static_links.
* objfiles.h (struct objfile) <static_links>: Now an htab_up.

gdb/ChangeLog
gdb/objfiles.c
gdb/objfiles.h
gdb/symfile.c

index 45f8fa50b209b7b512241e22c165509a1452922c..ac56b0957fa0eaec45ef73f72e0ba871aea1f98c 100644 (file)
@@ -1,3 +1,11 @@
+2019-04-19  Tom Tromey  <tom@tromey.com>
+
+       * symfile.c (reread_symbols): Update.
+       * objfiles.c (objfile_register_static_link)
+       (objfile_lookup_static_link): Update
+       (~objfile) Don't delete static_links.
+       * objfiles.h (struct objfile) <static_links>: Now an htab_up.
+
 2019-04-19  Tom Tromey  <tom@tromey.com>
 
        * type-stack.h (struct type_stack) <insert>: Constify string.
index e055365d37e0de0c72c6f5593b7733cdb9668927..1b0ea29980d4f5592f3b949fb6181e80e3a81972 100644 (file)
@@ -231,14 +231,14 @@ objfile_register_static_link (struct objfile *objfile,
   struct static_link_htab_entry *entry;
 
   if (objfile->static_links == NULL)
-    objfile->static_links = htab_create_alloc
+    objfile->static_links.reset (htab_create_alloc
       (1, &static_link_htab_entry_hash, static_link_htab_entry_eq, NULL,
-       xcalloc, xfree);
+       xcalloc, xfree));
 
   /* Create a slot for the mapping, make sure it's the first mapping for this
      block and then create the mapping itself.  */
   lookup_entry.block = block;
-  slot = htab_find_slot (objfile->static_links, &lookup_entry, INSERT);
+  slot = htab_find_slot (objfile->static_links.get (), &lookup_entry, INSERT);
   gdb_assert (*slot == NULL);
 
   entry = XOBNEW (&objfile->objfile_obstack, static_link_htab_entry);
@@ -260,9 +260,8 @@ objfile_lookup_static_link (struct objfile *objfile,
   if (objfile->static_links == NULL)
     return NULL;
   lookup_entry.block = block;
-  entry
-    = (struct static_link_htab_entry *) htab_find (objfile->static_links,
-                                                  &lookup_entry);
+  entry = ((struct static_link_htab_entry *)
+          htab_find (objfile->static_links.get (), &lookup_entry));
   if (entry == NULL)
     return NULL;
 
@@ -691,11 +690,6 @@ objfile::~objfile ()
 
   /* Rebuild section map next time we need it.  */
   get_objfile_pspace_data (pspace)->section_map_dirty = 1;
-
-  /* Free the map for static links.  There's no need to free static link
-     themselves since they were allocated on the objstack.  */
-  if (static_links != NULL)
-    htab_delete (static_links);
 }
 
 /* Free all the object files at once and clean up their users.  */
index 168f7fc275b4fdfa3e38820b6a02a6bdc5f9a7a4..e0ff8343439d40542a8cfd4967a21e7ed39be687 100644 (file)
@@ -615,7 +615,7 @@ struct objfile
      Very few blocks have a static link, so it's more memory efficient to
      store these here rather than in struct block.  Static links must be
      allocated on the objfile's obstack.  */
-  htab_t static_links {};
+  htab_up static_links;
 };
 
 /* Declarations for functions defined in objfiles.c */
index dd9c4ae985691366e7c3d813d58fdef20c2736c3..5736666506fe3bae8c82eeba7d21cbebb07dcdc4 100644 (file)
@@ -2549,7 +2549,7 @@ reread_symbols (void)
          objfile->sections = NULL;
          objfile->compunit_symtabs = NULL;
          objfile->template_symbols = NULL;
-         objfile->static_links = NULL;
+         objfile->static_links.reset (nullptr);
 
          /* obstack_init also initializes the obstack so it is
             empty.  We could use obstack_specify_allocation but