PR29262, memory leak in pr_function_type
[binutils-gdb.git] / gdb / completer.h
index 7bfe0d5814246ed086b253264e2d8e9bf40ad994..78e5240a95edf1428e92c549181dbde80c154918 100644 (file)
@@ -1,5 +1,5 @@
 /* Header for GDB line completion.
-   Copyright (C) 2000-2020 Free Software Foundation, Inc.
+   Copyright (C) 2000-2022 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -17,6 +17,7 @@
 #if !defined (COMPLETER_H)
 #define COMPLETER_H 1
 
+#include "gdbsupport/gdb-hashtab.h"
 #include "gdbsupport/gdb_vecs.h"
 #include "command.h"
 
@@ -242,7 +243,7 @@ struct completion_result
   DISABLE_COPY_AND_ASSIGN (completion_result);
 
   /* Move a result.  */
-  completion_result (completion_result &&rhs);
+  completion_result (completion_result &&rhs) noexcept;
 
   /* Release ownership of the match list array.  */
   char **release_match_list ();
@@ -326,6 +327,10 @@ public:
      LIST.  */
   void add_completions (completion_list &&list);
 
+  /* Remove completion matching NAME from the completion list, does nothing
+     if NAME is not already in the completion list.  */
+  void remove_completion (const char *name);
+
   /* Set the quote char to be appended after a unique completion is
      added to the input line.  Set to '\0' to clear.  See
      m_quote_char's description.  */
@@ -389,7 +394,7 @@ public:
 
   /* 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.  */
@@ -436,7 +441,7 @@ private:
      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