xref: /netbsd-src/external/gpl3/gdb/dist/gdbsupport/gdb-hashtab.cc (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 #include "gdb-hashtab.h"
204b169a6bSchristos 
214b169a6bSchristos /* Allocation function for the libiberty hash table which uses an
224b169a6bSchristos    obstack.  The obstack is passed as DATA.  */
234b169a6bSchristos 
244b169a6bSchristos void *
254b169a6bSchristos hashtab_obstack_allocate (void *data, size_t size, size_t count)
264b169a6bSchristos {
274b169a6bSchristos   size_t total = size * count;
284b169a6bSchristos   void *ptr = obstack_alloc ((struct obstack *) data, total);
294b169a6bSchristos 
304b169a6bSchristos   memset (ptr, 0, total);
314b169a6bSchristos   return ptr;
324b169a6bSchristos }
334b169a6bSchristos 
344b169a6bSchristos /* Trivial deallocation function for the libiberty splay tree and hash
354b169a6bSchristos    table - don't deallocate anything.  Rely on later deletion of the
364b169a6bSchristos    obstack.  DATA will be the obstack, although it is not needed
374b169a6bSchristos    here.  */
384b169a6bSchristos 
394b169a6bSchristos void
404b169a6bSchristos dummy_obstack_deallocate (void *object, void *data)
414b169a6bSchristos {
424b169a6bSchristos   return;
434b169a6bSchristos }
44