summaryrefslogtreecommitdiff
path: root/libiberty/hashtab.c
diff options
context:
space:
mode:
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2001-08-17 01:54:43 +0000
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2001-08-17 01:54:43 +0000
commit80f07f6c3bcc20a65ec64751ab55de0982e6afde (patch)
treed563cc31ac81eb04693b3b28a2d8f8911f038f76 /libiberty/hashtab.c
parent25fecab7965ee3319a4d55e45dcc042c342cd67a (diff)
downloadgcc-80f07f6c3bcc20a65ec64751ab55de0982e6afde.tar.gz
* hashtab.c (htab_hash_string): New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@44950 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libiberty/hashtab.c')
-rw-r--r--libiberty/hashtab.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/libiberty/hashtab.c b/libiberty/hashtab.c
index 274ad9ec207..28078027fef 100644
--- a/libiberty/hashtab.c
+++ b/libiberty/hashtab.c
@@ -561,3 +561,19 @@ htab_collisions (htab)
return (double) htab->collisions / (double) htab->searches;
}
+
+/* Hash P as a null-terminated string. */
+
+hashval_t
+htab_hash_string (p)
+ const PTR p;
+{
+ const unsigned char *str = (const unsigned char *) p;
+ hashval_t r = 0;
+ unsigned char c;
+
+ while ((c = *str++) != 0)
+ r = r * 67 + c - 113;
+
+ return r;
+}