[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
libihash fixes
From: |
Marco Gerards |
Subject: |
libihash fixes |
Date: |
Thu, 01 Apr 2004 20:02:42 +0200 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) |
Hi,
There is a minor bug in libihash and a mistake in the documentation in
ihash.h. See the patch I have included with this email.
Thanks,
Marco
2004-04-01 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.
diff -up ../libihash.orig/ihash.c ./ihash.c
--- ../libihash.orig/ihash.c 2004-03-24 23:53:19.000000000 +0100
+++ ./ihash.c 2004-04-01 18:45:08.000000000 +0200
@@ -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_i
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 -up ../libihash.orig/ihash.h ./ihash.h
--- ../libihash.orig/ihash.h 2004-03-24 23:53:19.000000000 +0100
+++ ./ihash.h 2004-04-01 18:45:08.000000000 +0200
@@ -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
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
- libihash fixes,
Marco Gerards <=