summaryrefslogtreecommitdiffstats
path: root/include/hashtab.h
diff options
context:
space:
mode:
authorcvs2svn <>2002-07-11 20:14:42 +0000
committercvs2svn <>2002-07-11 20:14:42 +0000
commitce122f0260fafd437209005104cb0d6cf24b6817 (patch)
treed5d0e21b67988b568d0630adec47856777c01b88 /include/hashtab.h
parent357281c75d7dbd491a9ce39121d36c2f0708cb51 (diff)
downloadcygnal-ce122f0260fafd437209005104cb0d6cf24b6817.tar.gz
cygnal-ce122f0260fafd437209005104cb0d6cf24b6817.tar.bz2
cygnal-ce122f0260fafd437209005104cb0d6cf24b6817.zip
This commit was manufactured by cvs2svn to create branch 'binutils-binutils-2_13-branchpoint
2_13-branch'. Sprout from kseitz_interps-20020528-branch 2002-06-18 21:15:59 UTC cvs2svn 'This commit was manufactured by cvs2svn to create branch' Cherrypick from master 2002-07-11 20:14:41 UTC DJ Delorie <dj@redhat.com> '* configure.in: Remove two redundant tests.': COPYING.LIBGLOSS ChangeLog Makefile.in config-ml.in config.sub config/ChangeLog configure configure.in etc/ChangeLog etc/texi2pod.pl include/ChangeLog include/bfdlink.h include/demangle.h include/dis-asm.h include/elf/ChangeLog include/elf/alpha.h include/elf/common.h include/elf/dwarf2.h include/elf/sh.h include/elf/vax.h include/fibheap.h include/gdb/ChangeLog include/gdb/sim-d10v.h include/getopt.h include/hashtab.h include/libiberty.h include/opcode/ChangeLog include/opcode/a29k.h include/opcode/convex.h include/opcode/dlx.h include/opcode/i386.h include/opcode/mips.h include/opcode/or32.h include/partition.h include/sort.h include/splay-tree.h ltcf-cxx.sh Delete: include/callback.h include/remote-sim.h
Diffstat (limited to 'include/hashtab.h')
-rw-r--r--include/hashtab.h41
1 files changed, 27 insertions, 14 deletions
diff --git a/include/hashtab.h b/include/hashtab.h
index 8871710e5..be866b51e 100644
--- a/include/hashtab.h
+++ b/include/hashtab.h
@@ -1,5 +1,5 @@
/* An expandable hash tables datatype.
- Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
Contributed by Vladimir Makarov (vmakarov@cygnus.com).
This program is free software; you can redistribute it and/or modify
@@ -36,7 +36,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
extern "C" {
#endif /* __cplusplus */
-#include <ansidecl.h>
+#include "ansidecl.h"
+
+#ifndef GTY
+#define GTY(X)
+#endif
/* The type for a hash code. */
typedef unsigned int hashval_t;
@@ -63,12 +67,21 @@ typedef void (*htab_del) PARAMS ((void *));
htab_traverse. Return 1 to continue scan, 0 to stop. */
typedef int (*htab_trav) PARAMS ((void **, void *));
+/* Memory-allocation function, with the same functionality as calloc().
+ Iff it returns NULL, the hash table implementation will pass an error
+ code back to the user, so if your code doesn't handle errors,
+ best if you use xcalloc instead. */
+typedef PTR (*htab_alloc) PARAMS ((size_t, size_t));
+
+/* We also need a free() routine. */
+typedef void (*htab_free) PARAMS ((PTR));
+
/* Hash tables are of the following type. The structure
(implementation) of this type is not needed for using the hash
tables. All work with hash table should be executed only through
functions mentioned below. */
-struct htab
+struct htab GTY(())
{
/* Pointer to hash function. */
htab_hash hash_f;
@@ -80,7 +93,7 @@ struct htab
htab_del del_f;
/* Table itself. */
- PTR *entries;
+ PTR * GTY ((use_param (""), length ("%h.size"))) entries;
/* Current size (in entries) of the hash table */
size_t size;
@@ -99,9 +112,9 @@ struct htab
of collisions fixed for time of work with the hash table. */
unsigned int collisions;
- /* This is non-zero if we are allowed to return NULL for function calls
- that allocate memory. */
- int return_allocation_failure;
+ /* Pointers to allocate/free functions. */
+ htab_alloc alloc_f;
+ htab_free free_f;
};
typedef struct htab *htab_t;
@@ -111,14 +124,14 @@ enum insert_option {NO_INSERT, INSERT};
/* The prototypes of the package functions. */
-extern htab_t htab_create PARAMS ((size_t, htab_hash,
- htab_eq, htab_del));
+extern htab_t htab_create_alloc PARAMS ((size_t, htab_hash,
+ htab_eq, htab_del,
+ htab_alloc, htab_free));
+
+/* Backward-compatibility functions. */
+extern htab_t htab_create PARAMS ((size_t, htab_hash, htab_eq, htab_del));
+extern htab_t htab_try_create PARAMS ((size_t, htab_hash, htab_eq, htab_del));
-/* This function is like htab_create, but may return NULL if memory
- allocation fails, and also signals that htab_find_slot_with_hash and
- htab_find_slot are allowed to return NULL when inserting. */
-extern htab_t htab_try_create PARAMS ((size_t, htab_hash,
- htab_eq, htab_del));
extern void htab_delete PARAMS ((htab_t));
extern void htab_empty PARAMS ((htab_t));