xref: /netbsd-src/external/gpl3/gdb.old/dist/gdbsupport/gdb-hashtab.cc (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 #include "common-defs.h"
20*6881a400Schristos #include "gdb-hashtab.h"
21*6881a400Schristos 
22*6881a400Schristos /* Allocation function for the libiberty hash table which uses an
23*6881a400Schristos    obstack.  The obstack is passed as DATA.  */
24*6881a400Schristos 
25*6881a400Schristos void *
26*6881a400Schristos hashtab_obstack_allocate (void *data, size_t size, size_t count)
27*6881a400Schristos {
28*6881a400Schristos   size_t total = size * count;
29*6881a400Schristos   void *ptr = obstack_alloc ((struct obstack *) data, total);
30*6881a400Schristos 
31*6881a400Schristos   memset (ptr, 0, total);
32*6881a400Schristos   return ptr;
33*6881a400Schristos }
34*6881a400Schristos 
35*6881a400Schristos /* Trivial deallocation function for the libiberty splay tree and hash
36*6881a400Schristos    table - don't deallocate anything.  Rely on later deletion of the
37*6881a400Schristos    obstack.  DATA will be the obstack, although it is not needed
38*6881a400Schristos    here.  */
39*6881a400Schristos 
40*6881a400Schristos void
41*6881a400Schristos dummy_obstack_deallocate (void *object, void *data)
42*6881a400Schristos {
43*6881a400Schristos   return;
44*6881a400Schristos }
45