diff options
-rw-r--r-- | libihash/ChangeLog | 7 | ||||
-rw-r--r-- | libihash/ihash.c | 19 | ||||
-rw-r--r-- | libihash/ihash.h | 4 |
3 files changed, 20 insertions, 10 deletions
diff --git a/libihash/ChangeLog b/libihash/ChangeLog index 1d71c115..75e73476 100644 --- a/libihash/ChangeLog +++ b/libihash/ChangeLog @@ -1,3 +1,10 @@ +2004-04-02 Marco Gerards <metgerards@student.han.nl> + + * ihash.c (hurd_ihash_remove): Don't look for the index when the + hashtable is empty. + + * ihash.h (HURD_IHASH_ITERATE): Doc fix. + 2004-03-07 Marcus Brinkmann <marcus@gnu.org> * ihash.h (HURD_IHASH_NO_LOCP): Change to INTPTR_MIN. diff --git a/libihash/ihash.c b/libihash/ihash.c index a6b96376..8fa9d514 100644 --- a/libihash/ihash.c +++ b/libihash/ihash.c @@ -1,5 +1,5 @@ /* ihash.c - Integer-keyed hash table functions. - Copyright (C) 1993-1997, 2001, 2003 Free Software Foundation, Inc. + Copyright (C) 1993-1997, 2001, 2003, 2004 Free Software Foundation, Inc. Written by Michael I. Bushnell. Revised by Miles Bader <miles@gnu.org>. Revised by Marcus Brinkmann <marcus@gnu.org>. @@ -419,15 +419,18 @@ hurd_ihash_find (hurd_ihash_t ht, hurd_ihash_key_t key) int hurd_ihash_remove (hurd_ihash_t ht, hurd_ihash_key_t key) { - int idx = find_index (ht, key); - - if (index_valid (ht, idx, key)) + if (ht->size != 0) { - locp_remove (ht, &ht->items[idx].value); - return 1; + int idx = find_index (ht, key); + + if (index_valid (ht, idx, key)) + { + locp_remove (ht, &ht->items[idx].value); + return 1; + } } - else - return 0; + + return 0; } diff --git a/libihash/ihash.h b/libihash/ihash.h index 8f537edb..0be65efe 100644 --- a/libihash/ihash.h +++ b/libihash/ihash.h @@ -1,5 +1,5 @@ /* ihash.h - Integer keyed hash table interface. - Copyright (C) 1995, 2003 Free Software Foundation, Inc. + Copyright (C) 1995, 2003, 2004 Free Software Foundation, Inc. Written by Miles Bader <miles@gnu.org>. Revised by Marcus Brinkmann <marcus@gnu.org>. @@ -180,7 +180,7 @@ hurd_ihash_value_t hurd_ihash_find (hurd_ihash_t ht, hurd_ihash_key_t key); Or even like this: - hurd_ihash_iterate (ht, value) + HURD_IHASH_ITERATE (ht, value) foo (value); The block will be run for every element in the hash table HT. The |