[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-gnulib] hash.c change to use abort rather than assert
From: |
Paul Eggert |
Subject: |
Re: [Bug-gnulib] hash.c change to use abort rather than assert |
Date: |
Wed, 27 Nov 2002 16:41:36 -0800 |
> Date: Wed, 27 Nov 2002 15:03:40 +0100 (CET)
> From: Bruno Haible <address@hidden>
>
> My point is that assert() does all that aver() does, PLUS it is
> standard, i.e. everyone knows it.
If we want standard code, perhaps we should just stick to `if (x)
abort ();'. I installed this patch, which addresses your original
point. Perhaps if someone has time to inspect the code carefully, we
can remove the checks.
2002-11-27 Paul Eggert <address@hidden>
* hash.c (hash_lookup, hash_get_first, hash_get_next, hash_find_entry,
hash_rehash): Replace `if (limit <= value) abort ();' with
`if (! (value < limit)) abort ();', for readability.
Index: hash.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/hash.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -p -u -r1.29 -r1.30
--- hash.c 23 Nov 2002 07:02:40 -0000 1.29
+++ hash.c 28 Nov 2002 00:34:24 -0000 1.30
@@ -262,7 +262,7 @@ hash_lookup (const Hash_table *table, co
= table->bucket + table->hasher (entry, table->n_buckets);
struct hash_entry *cursor;
- if (table->bucket_limit <= bucket)
+ if (! (bucket < table->bucket_limit))
abort ();
if (bucket->data == NULL)
@@ -293,7 +293,7 @@ hash_get_first (const Hash_table *table)
return NULL;
for (bucket = table->bucket; ; bucket++)
- if (table->bucket_limit <= bucket)
+ if (! (bucket < table->bucket_limit))
abort ();
else if (bucket->data)
return bucket->data;
@@ -310,7 +310,7 @@ hash_get_next (const Hash_table *table,
= table->bucket + table->hasher (entry, table->n_buckets);
struct hash_entry *cursor;
- if (table->bucket_limit <= bucket)
+ if (! (bucket < table->bucket_limit))
abort ();
/* Find next entry in the same bucket. */
@@ -754,7 +754,7 @@ hash_find_entry (Hash_table *table, cons
= table->bucket + table->hasher (entry, table->n_buckets);
struct hash_entry *cursor;
- if (table->bucket_limit <= bucket)
+ if (! (bucket < table->bucket_limit))
abort ();
*bucket_head = bucket;
@@ -850,7 +850,7 @@ hash_rehash (Hash_table *table, unsigned
= (new_table->bucket
+ new_table->hasher (data, new_table->n_buckets));
- if (new_table->bucket_limit <= new_bucket)
+ if (! (new_bucket < new_table->bucket_limit))
abort ();
next = cursor->next;