xref: /netbsd-src/external/gpl3/gdb.old/dist/gdbsupport/gdb-hashtab.h (revision 6881a4007f077b54e5f51159c52b9b25f57deb0d)
1*6881a400Schristos /* Hash table wrappers for gdb.
2*6881a400Schristos    Copyright (C) 2021-2023 Free Software Foundation, Inc.
3*6881a400Schristos 
4*6881a400Schristos    This file is part of GDB.
5*6881a400Schristos 
6*6881a400Schristos    This program is free software; you can redistribute it and/or modify
7*6881a400Schristos    it under the terms of the GNU General Public License as published by
8*6881a400Schristos    the Free Software Foundation; either version 3 of the License, or
9*6881a400Schristos    (at your option) any later version.
10*6881a400Schristos 
11*6881a400Schristos    This program is distributed in the hope that it will be useful,
12*6881a400Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
13*6881a400Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14*6881a400Schristos    GNU General Public License for more details.
15*6881a400Schristos 
16*6881a400Schristos    You should have received a copy of the GNU General Public License
17*6881a400Schristos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
18*6881a400Schristos 
19*6881a400Schristos #ifndef GDBSUPPORT_GDB_HASHTAB_H
20*6881a400Schristos #define GDBSUPPORT_GDB_HASHTAB_H
21*6881a400Schristos 
22*6881a400Schristos #include "hashtab.h"
23*6881a400Schristos 
24*6881a400Schristos /* A deleter for a hash table.  */
25*6881a400Schristos struct htab_deleter
26*6881a400Schristos {
27*6881a400Schristos   void operator() (htab *ptr) const
28*6881a400Schristos   {
29*6881a400Schristos     htab_delete (ptr);
30*6881a400Schristos   }
31*6881a400Schristos };
32*6881a400Schristos 
33*6881a400Schristos /* A unique_ptr wrapper for htab_t.  */
34*6881a400Schristos typedef std::unique_ptr<htab, htab_deleter> htab_up;
35*6881a400Schristos 
36*6881a400Schristos /* A wrapper for 'delete' that can used as a hash table entry deletion
37*6881a400Schristos    function.  */
38*6881a400Schristos template<typename T>
39*6881a400Schristos void
40*6881a400Schristos htab_delete_entry (void *ptr)
41*6881a400Schristos {
42*6881a400Schristos   delete (T *) ptr;
43*6881a400Schristos }
44*6881a400Schristos 
45*6881a400Schristos /* Allocation and deallocation functions for the libiberty hash table
46*6881a400Schristos    which use obstacks.  */
47*6881a400Schristos void *hashtab_obstack_allocate (void *data, size_t size, size_t count);
48*6881a400Schristos void dummy_obstack_deallocate (void *object, void *data);
49*6881a400Schristos 
50*6881a400Schristos #endif /* GDBSUPPORT_GDB_HASHTAB_H */
51