From: Tom Tromey Date: Thu, 17 Sep 2020 17:47:50 +0000 (-0600) Subject: Use htab_up in filename_seen_cache X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=99032cfcc6c12006ba6184318c5df5b08a65e58a;p=binutils-gdb.git Use htab_up in filename_seen_cache This changes filename_seen_cache to use htab_up, rather than explicit calls to htab_delete. gdb/ChangeLog 2020-09-17 Tom Tromey * filename-seen-cache.c (filename_seen_cache::filename_seen_cache) (filename_seen_cache::clear): Update. (~filename_seen_cache): Remove. (filename_seen_cache::seen): Update. * filename-seen-cache.h (class filename_seen_cache) : Now htab_up. <~filename_seen_cache>: Remove. : Update. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 8f8f7a9174b..c61626b6764 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,14 @@ +2020-09-17 Tom Tromey + + * filename-seen-cache.c (filename_seen_cache::filename_seen_cache) + (filename_seen_cache::clear): Update. + (~filename_seen_cache): Remove. + (filename_seen_cache::seen): Update. + * filename-seen-cache.h (class filename_seen_cache) : Now + htab_up. + <~filename_seen_cache>: Remove. + : Update. + 2020-09-17 Tom Tromey * completer.c (completion_tracker::discard_completions) diff --git a/gdb/filename-seen-cache.c b/gdb/filename-seen-cache.c index f3905c0fb12..b0cda087cc0 100644 --- a/gdb/filename-seen-cache.c +++ b/gdb/filename-seen-cache.c @@ -27,10 +27,10 @@ /* filename_seen_cache constructor. */ filename_seen_cache::filename_seen_cache () + : m_tab (htab_create_alloc (INITIAL_FILENAME_SEEN_CACHE_SIZE, + filename_hash, filename_eq, + NULL, xcalloc, xfree)) { - m_tab = htab_create_alloc (INITIAL_FILENAME_SEEN_CACHE_SIZE, - filename_hash, filename_eq, - NULL, xcalloc, xfree); } /* See filename-seen-cache.h. */ @@ -38,14 +38,7 @@ filename_seen_cache::filename_seen_cache () void filename_seen_cache::clear () { - htab_empty (m_tab); -} - -/* See filename-seen-cache.h. */ - -filename_seen_cache::~filename_seen_cache () -{ - htab_delete (m_tab); + htab_empty (m_tab.get ()); } /* See filename-seen-cache.h. */ @@ -56,7 +49,7 @@ filename_seen_cache::seen (const char *file) void **slot; /* Is FILE in tab? */ - slot = htab_find_slot (m_tab, file, INSERT); + slot = htab_find_slot (m_tab.get (), file, INSERT); if (*slot != NULL) return true; diff --git a/gdb/filename-seen-cache.h b/gdb/filename-seen-cache.h index ee064c32565..3d8cedf8080 100644 --- a/gdb/filename-seen-cache.h +++ b/gdb/filename-seen-cache.h @@ -29,7 +29,6 @@ class filename_seen_cache { public: filename_seen_cache (); - ~filename_seen_cache (); DISABLE_COPY_AND_ASSIGN (filename_seen_cache); @@ -55,12 +54,12 @@ public: return 1; }; - htab_traverse_noresize (m_tab, erased_cb, &callback); + htab_traverse_noresize (m_tab.get (), erased_cb, &callback); } private: /* Table of files seen so far. */ - htab_t m_tab; + htab_up m_tab; }; #endif /* FILENAME_SEEN_CACHE_H */