+2020-09-17 Tom Tromey <tom@tromey.com>
+
+ * completer.c (completion_tracker::discard_completions)
+ (completion_tracker::~completion_tracker)
+ (completion_tracker::maybe_add_completion)
+ (completion_tracker::remove_completion)
+ (completion_tracker::recompute_lowest_common_denominator)
+ (completion_tracker::build_completion_result): Update.
+ * completer.h (class completion_tracker) <have_completions>:
+ Update.
+ <m_entries_hash>: Now htab_up.
+
2020-09-17 Tom Tromey <tom@tromey.com>
* breakpoint.c (ambiguous_names_p): Use htab_up.
m_lowest_common_denominator_unique = false;
m_lowest_common_denominator_valid = false;
- /* A null check here allows this function to be used from the
- constructor. */
- if (m_entries_hash != NULL)
- htab_delete (m_entries_hash);
+ m_entries_hash.reset (nullptr);
/* A callback used by the hash table to compare new entries with existing
entries. We can't use the standard streq_hash function here as the
return entry->hash_name ();
};
- m_entries_hash = htab_create_alloc (INITIAL_COMPLETION_HTAB_SIZE,
- entry_hash_func, entry_eq_func,
- completion_hash_entry::deleter,
- xcalloc, xfree);
+ m_entries_hash.reset (htab_create_alloc (INITIAL_COMPLETION_HTAB_SIZE,
+ entry_hash_func, entry_eq_func,
+ completion_hash_entry::deleter,
+ xcalloc, xfree));
}
/* See completer.h. */
completion_tracker::~completion_tracker ()
{
xfree (m_lowest_common_denominator);
- htab_delete (m_entries_hash);
}
/* See completer.h. */
if (max_completions == 0)
return false;
- if (htab_elements (m_entries_hash) >= max_completions)
+ if (htab_elements (m_entries_hash.get ()) >= max_completions)
return false;
hashval_t hash = htab_hash_string (name.get ());
- slot = htab_find_slot_with_hash (m_entries_hash, name.get (), hash, INSERT);
+ slot = htab_find_slot_with_hash (m_entries_hash.get (), name.get (),
+ hash, INSERT);
if (*slot == HTAB_EMPTY_ENTRY)
{
const char *match_for_lcd_str = NULL;
completion_tracker::remove_completion (const char *name)
{
hashval_t hash = htab_hash_string (name);
- if (htab_find_slot_with_hash (m_entries_hash, name, hash, NO_INSERT)
+ if (htab_find_slot_with_hash (m_entries_hash.get (), name, hash, NO_INSERT)
!= NULL)
{
- htab_remove_elt_with_hash (m_entries_hash, name, hash);
+ htab_remove_elt_with_hash (m_entries_hash.get (), name, hash);
m_lowest_common_denominator_valid = false;
}
}
return 1;
};
- htab_traverse (m_entries_hash, visitor_func, this);
+ htab_traverse (m_entries_hash.get (), visitor_func, this);
m_lowest_common_denominator_valid = true;
}
completion_tracker::build_completion_result (const char *text,
int start, int end)
{
- size_t element_count = htab_elements (m_entries_hash);
+ size_t element_count = htab_elements (m_entries_hash.get ());
if (element_count == 0)
return {};
};
/* Build the completion list and add a null at the end. */
- htab_traverse_noresize (m_entries_hash, func, &builder);
+ htab_traverse_noresize (m_entries_hash.get (), func, &builder);
match_list[builder.index] = NULL;
return completion_result (match_list, builder.index - 1, false);
/* True if we have any completion match recorded. */
bool have_completions () const
- { return htab_elements (m_entries_hash) > 0; }
+ { return htab_elements (m_entries_hash.get ()) > 0; }
/* Discard the current completion match list and the current
LCD. */
will remove duplicates, and if removal of duplicates there brings
the total under max_completions the user may think gdb quit
searching too early. */
- htab_t m_entries_hash = NULL;
+ htab_up m_entries_hash;
/* If non-zero, then this is the quote char that needs to be
appended after completion (iff we have a unique completion). We