diff options
author | Richard Henderson <rth@redhat.com> | 2001-08-16 18:54:43 -0700 |
---|---|---|
committer | Richard Henderson <rth@gcc.gnu.org> | 2001-08-16 18:54:43 -0700 |
commit | 9e0ba68596a905bf69b818a2747c9a4e20cf16cd (patch) | |
tree | d563cc31ac81eb04693b3b28a2d8f8911f038f76 /libiberty | |
parent | 457f49df106a2ac222c1d86f6638c0337ed3f996 (diff) | |
download | gcc-9e0ba68596a905bf69b818a2747c9a4e20cf16cd.zip gcc-9e0ba68596a905bf69b818a2747c9a4e20cf16cd.tar.gz gcc-9e0ba68596a905bf69b818a2747c9a4e20cf16cd.tar.bz2 |
* hashtab.c (htab_hash_string): New.
From-SVN: r44950
Diffstat (limited to 'libiberty')
-rw-r--r-- | libiberty/ChangeLog | 4 | ||||
-rw-r--r-- | libiberty/hashtab.c | 16 |
2 files changed, 20 insertions, 0 deletions
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index a62db15..84653bb 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,7 @@ +2001-08-16 Richard Henderson <rth@redhat.com> + + * hashtab.c (htab_hash_string): New. + 2001-08-13 Andrew Cagney <ac131313@redhat.com> * floatformat.c (floatformat_ieee_double_littlebyte_bigword): Fix diff --git a/libiberty/hashtab.c b/libiberty/hashtab.c index 274ad9e..2807802 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; +} |