/* hash - hashing table processing.
- Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
Written by Jim Meyering, 1992.
This program is free software; you can redistribute it and/or modify
typedef enum {false = 0, true = 1} bool;
#endif
#include <stdio.h>
-#include <assert.h>
#ifndef HAVE_DECL_FREE
"this configure-time declaration test was not run"
= table->bucket + table->hasher (entry, table->n_buckets);
struct hash_entry *cursor;
- assert (bucket < table->bucket_limit);
+ if (! (bucket < table->bucket_limit))
+ abort ();
if (bucket->data == NULL)
return NULL;
if (table->n_entries == 0)
return NULL;
- for (bucket = table->bucket; bucket < table->bucket_limit; bucket++)
- if (bucket->data)
+ for (bucket = table->bucket; ; bucket++)
+ if (! (bucket < table->bucket_limit))
+ abort ();
+ else if (bucket->data)
return bucket->data;
-
- assert (0);
- return NULL;
}
/* Return the user data for the entry following ENTRY, where ENTRY has been
= table->bucket + table->hasher (entry, table->n_buckets);
struct hash_entry *cursor;
- assert (bucket < table->bucket_limit);
+ if (! (bucket < table->bucket_limit))
+ abort ();
/* Find next entry in the same bucket. */
for (cursor = bucket; cursor; cursor = cursor->next)
= table->bucket + table->hasher (entry, table->n_buckets);
struct hash_entry *cursor;
- assert (bucket < table->bucket_limit);
+ if (! (bucket < table->bucket_limit))
+ abort ();
+
*bucket_head = bucket;
/* Test for empty bucket. */
= (new_table->bucket
+ new_table->hasher (data, new_table->n_buckets));
- assert (new_bucket < new_table->bucket_limit);
+ if (! (new_bucket < new_table->bucket_limit))
+ abort ();
+
next = cursor->next;
if (new_bucket->data)
void *data;
struct hash_entry *bucket;
- assert (entry); /* cannot insert a NULL entry */
+ /* The caller cannot insert a NULL entry. */
+ if (! entry)
+ abort ();
/* If there's a matching entry already in the table, return that. */
if ((data = hash_find_entry (table, entry, &bucket, false)) != NULL)