From f7f606641f373b3af829cef22d8d25549176d7e4 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Fri, 31 Oct 2003 14:00:18 +0000 Subject: Update from gnulib. --- lib/hash-pjw.h | 6 +++++- lib/hash.c | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/hash-pjw.h b/lib/hash-pjw.h index b2a099494..5847a2528 100644 --- a/lib/hash-pjw.h +++ b/lib/hash-pjw.h @@ -18,4 +18,8 @@ #include -size_t hash_pjw (void const *x, size_t tablesize); +/* Compute a hash code for a NUL-terminated string starting at X, + and return the hash code modulo TABLESIZE. + The result is platform dependent: it depends on the size of the 'size_t' + type and on the signedness of the 'char' type. */ +extern size_t hash_pjw (void const *x, size_t tablesize); diff --git a/lib/hash.c b/lib/hash.c index ad4599e4d..19e593fef 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -568,10 +568,10 @@ hash_initialize (size_t candidate, const Hash_tuning *tuning, candidate = new_candidate; } - if (SIZE_MAX / sizeof *table->bucket < candidate) + if (xalloc_oversized (candidate, sizeof *table->bucket)) goto fail; table->n_buckets = next_prime (candidate); - if (SIZE_MAX / sizeof *table->bucket < table->n_buckets) + if (xalloc_oversized (table->n_buckets, sizeof *table->bucket)) goto fail; table->bucket = calloc (table->n_buckets, sizeof *table->bucket); -- cgit v1.2.3-54-g00ecf