/* Implement a cached obstack.
Written by Fred Fish <fnf@cygnus.com>
Rewritten by Jim Blandy <jimb@cygnus.com>
- Copyright 1999 Free Software Foundation, Inc.
+
+ Copyright 1999, 2000, 2002 Free Software Foundation, Inc.
This file is part of GDB.
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#include <stddef.h>
-#include <stdlib.h>
-
#include "defs.h"
#include "obstack.h"
#include "bcache.h"
#include "gdb_string.h" /* For memcpy declaration */
+#include <stddef.h>
+#include <stdlib.h>
+
/* The old hash function was stolen from SDBM. This is what DB 3.0 uses now,
* and is better than the old one.
*/
\f
unsigned long
-hash(void *addr, int length)
+hash(const void *addr, int length)
{
const unsigned char *k, *e;
unsigned long h;
/* Plug in the new table. */
if (bcache->bucket)
- free (bcache->bucket);
+ xfree (bcache->bucket);
bcache->bucket = new_buckets;
bcache->num_buckets = new_num_buckets;
}
never seen those bytes before, add a copy of them to BCACHE. In
either case, return a pointer to BCACHE's copy of that string. */
void *
-bcache (void *addr, int length, struct bcache *bcache)
+bcache (const void *addr, int length, struct bcache *bcache)
{
int hash_index;
struct bstring *s;
{
obstack_free (&bcache->cache, 0);
if (bcache->bucket)
- free (bcache->bucket);
+ xfree (bcache->bucket);
/* This isn't necessary, but at least the bcache is always in a
consistent state. */