X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fhash.c;h=5899f57c3d552bd6dec65533bba016a1307e3437;hb=c52618d1e7305ada7afba73b6b0452bb8d6983cb;hp=200d3c02bb54ad0b6a167fa94080b136d8ed95ac;hpb=6845df702a8df510b0d40c19069ee8d893722a9d;p=gnulib.git diff --git a/lib/hash.c b/lib/hash.c index 200d3c02b..5899f57c3 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -264,7 +264,8 @@ hash_get_next (const Hash_table *table, const void *entry) pointers. */ unsigned int -hash_get_entries (const Hash_table *table, void **buffer, unsigned int buffer_size) +hash_get_entries (const Hash_table *table, void **buffer, + unsigned int buffer_size) { unsigned int counter = 0; struct hash_entry *bucket; @@ -375,9 +376,8 @@ hash_string (const char *string, unsigned int n_buckets) /* Return true if CANDIDATE is a prime number. CANDIDATE should be an odd number at least equal to 11. */ -static bool -is_prime (candidate) - unsigned long candidate; +static int +is_prime (unsigned long candidate) { unsigned long divisor = 3; unsigned long square = divisor * divisor; @@ -396,9 +396,10 @@ is_prime (candidate) prime. CANDIDATE should be at least equal to 10. */ static unsigned long -next_prime (candidate) - unsigned long candidate; +next_prime (unsigned long candidate) { + assert (candidate >= 10); + /* Make it definitely odd. */ candidate |= 1; @@ -409,10 +410,11 @@ next_prime (candidate) } /* Allocate and return a new hash table, or NULL if an error is met. The - initial number of buckets would be at least CANDIDATE (which need not be prime). + initial number of buckets would be at least CANDIDATE (which need not be + prime). - If DATA_FREER is not NULL, this function may be later called with the data as - an argument, just before they entry containing the data gets freed. The + If DATA_FREER is not NULL, this function may be later called with the data + as an argument, just before they entry containing the data gets freed. The HASHER function should be supplied, and FIXME. The COMPARATOR function should also be supplied, and FIXME. */