xref: /netbsd-src/external/gpl3/gdb/dist/gdbsupport/gdb-hashtab.h (revision 5ba1f45f2a09259cc846f20c7c5501604d633c90)
14b169a6bSchristos /* Hash table wrappers for gdb.
2*5ba1f45fSchristos    Copyright (C) 2021-2024 Free Software Foundation, Inc.
34b169a6bSchristos 
44b169a6bSchristos    This file is part of GDB.
54b169a6bSchristos 
64b169a6bSchristos    This program is free software; you can redistribute it and/or modify
74b169a6bSchristos    it under the terms of the GNU General Public License as published by
84b169a6bSchristos    the Free Software Foundation; either version 3 of the License, or
94b169a6bSchristos    (at your option) any later version.
104b169a6bSchristos 
114b169a6bSchristos    This program is distributed in the hope that it will be useful,
124b169a6bSchristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
134b169a6bSchristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
144b169a6bSchristos    GNU General Public License for more details.
154b169a6bSchristos 
164b169a6bSchristos    You should have received a copy of the GNU General Public License
174b169a6bSchristos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
184b169a6bSchristos 
194b169a6bSchristos #ifndef GDBSUPPORT_GDB_HASHTAB_H
204b169a6bSchristos #define GDBSUPPORT_GDB_HASHTAB_H
214b169a6bSchristos 
224b169a6bSchristos #include "hashtab.h"
234b169a6bSchristos 
244b169a6bSchristos /* A deleter for a hash table.  */
254b169a6bSchristos struct htab_deleter
264b169a6bSchristos {
274b169a6bSchristos   void operator() (htab *ptr) const
284b169a6bSchristos   {
294b169a6bSchristos     htab_delete (ptr);
304b169a6bSchristos   }
314b169a6bSchristos };
324b169a6bSchristos 
334b169a6bSchristos /* A unique_ptr wrapper for htab_t.  */
344b169a6bSchristos typedef std::unique_ptr<htab, htab_deleter> htab_up;
354b169a6bSchristos 
364b169a6bSchristos /* A wrapper for 'delete' that can used as a hash table entry deletion
374b169a6bSchristos    function.  */
384b169a6bSchristos template<typename T>
394b169a6bSchristos void
404b169a6bSchristos htab_delete_entry (void *ptr)
414b169a6bSchristos {
424b169a6bSchristos   delete (T *) ptr;
434b169a6bSchristos }
444b169a6bSchristos 
454b169a6bSchristos /* Allocation and deallocation functions for the libiberty hash table
464b169a6bSchristos    which use obstacks.  */
474b169a6bSchristos void *hashtab_obstack_allocate (void *data, size_t size, size_t count);
484b169a6bSchristos void dummy_obstack_deallocate (void *object, void *data);
494b169a6bSchristos 
504b169a6bSchristos #endif /* GDBSUPPORT_GDB_HASHTAB_H */
51