[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 25/75: libihash: fix ill-devised locp lookup interface
From: |
Samuel Thibault |
Subject: |
[hurd] 25/75: libihash: fix ill-devised locp lookup interface |
Date: |
Thu, 14 Jan 2016 01:04:07 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch dde
in repository hurd.
commit e6fdb474b7fc4237b19d8405074930518ac02b27
Author: Justus Winter <address@hidden>
Date: Sat Nov 21 16:12:53 2015 +0100
libihash: fix ill-devised locp lookup interface
* libihash/ihash.c (hurd_ihash_locp_find): Return both the item and the
slot.
* libihash/ihash.h (hurd_ihash_locp_find): Adjust prototype.
(hurd_ihash_locp_value): Remove function.
---
libihash/ihash.c | 19 +++++++++----------
libihash/ihash.h | 31 ++++++-------------------------
2 files changed, 15 insertions(+), 35 deletions(-)
diff --git a/libihash/ihash.c b/libihash/ihash.c
index 87d7abf..8b1ad1f 100644
--- a/libihash/ihash.c
+++ b/libihash/ihash.c
@@ -370,13 +370,9 @@ hurd_ihash_find (hurd_ihash_t ht, hurd_ihash_key_t key)
}
}
-/* Find the item in the hash table HT with key KEY. If it is found,
- return the location of its slot in the hash table. If it is not
- found, this function may still return a location.
-
- This location pointer can always be safely accessed using
- hurd_ihash_locp_value. If the lookup is successful,
- hurd_ihash_locp_value will return the value related to KEY.
+/* Find and return the item in the hash table HT with key KEY, or NULL
+ if it doesn't exist. If it is not found, this function may still
+ return a location in SLOT.
If the lookup is successful, the returned location can be used with
hurd_ihash_locp_add to update the item, and with
@@ -387,8 +383,10 @@ hurd_ihash_find (hurd_ihash_t ht, hurd_ihash_key_t key)
Note that returned location is only valid until the next insertion
or deletion. */
-hurd_ihash_locp_t
-hurd_ihash_locp_find (hurd_ihash_t ht, hurd_ihash_key_t key)
+hurd_ihash_value_t
+hurd_ihash_locp_find (hurd_ihash_t ht,
+ hurd_ihash_key_t key,
+ hurd_ihash_locp_t *slot)
{
int idx;
@@ -396,7 +394,8 @@ hurd_ihash_locp_find (hurd_ihash_t ht, hurd_ihash_key_t key)
return NULL;
idx = find_index (ht, key);
- return &ht->items[idx].value;
+ *slot = &ht->items[idx].value;
+ return index_valid (ht, idx, key) ? ht->items[idx].value : NULL;
}
diff --git a/libihash/ihash.h b/libihash/ihash.h
index 1dbc348..fdfc367 100644
--- a/libihash/ihash.h
+++ b/libihash/ihash.h
@@ -218,13 +218,9 @@ error_t hurd_ihash_locp_add (hurd_ihash_t ht,
hurd_ihash_locp_t locp,
if it doesn't exist. */
hurd_ihash_value_t hurd_ihash_find (hurd_ihash_t ht, hurd_ihash_key_t key);
-/* Find the item in the hash table HT with key KEY. If it is found,
- return the location of its slot in the hash table. If it is not
- found, this function may still return a location.
-
- This location pointer can always be safely accessed using
- hurd_ihash_locp_value. If the lookup is successful,
- hurd_ihash_locp_value will return the value related to KEY.
+/* Find and return the item in the hash table HT with key KEY, or NULL
+ if it doesn't exist. If it is not found, this function may still
+ return a location in SLOT.
If the lookup is successful, the returned location can be used with
hurd_ihash_locp_add to update the item, and with
@@ -235,24 +231,9 @@ hurd_ihash_value_t hurd_ihash_find (hurd_ihash_t ht,
hurd_ihash_key_t key);
Note that returned location is only valid until the next insertion
or deletion. */
-hurd_ihash_locp_t hurd_ihash_locp_find (hurd_ihash_t ht,
- hurd_ihash_key_t key);
-
-/* Given an hash table bucket location LOCP, return the value stored
- there, or NULL if it is empty or LOCP is NULL. */
-static inline void *
-hurd_ihash_locp_value (hurd_ihash_locp_t locp)
-{
- struct _hurd_ihash_item *item = (struct _hurd_ihash_item *) locp;
-
- if (item == NULL)
- return NULL;
-
- if (hurd_ihash_value_valid (item->value))
- return item->value;
-
- return NULL;
-}
+hurd_ihash_value_t hurd_ihash_locp_find (hurd_ihash_t ht,
+ hurd_ihash_key_t key,
+ hurd_ihash_locp_t *slot);
/* Iterate over all elements in the hash table. You use this macro
with a block, for example like this:
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] 19/75: Add devnode documentation, (continued)
- [hurd] 19/75: Add devnode documentation, Samuel Thibault, 2016/01/13
- [hurd] 23/75: Add missing menus, Samuel Thibault, 2016/01/13
- [hurd] 20/75: Merge branch 'master' of git.savannah.gnu.org:/srv/git/hurd/hurd into dde, Samuel Thibault, 2016/01/13
- [hurd] 12/75: Merge branch 'dde' of ssh://git.savannah.gnu.org/srv/git/hurd/incubator into dde, Samuel Thibault, 2016/01/13
- [hurd] 02/75: libtrivfs: remove deprecated static class vectors, Samuel Thibault, 2016/01/13
- [hurd] 05/75: random: improve error handling, Samuel Thibault, 2016/01/13
- [hurd] 01/75: pfinet: fix sanity check at translator startup time, Samuel Thibault, 2016/01/13
- [hurd] 22/75: Fix undefined reference, Samuel Thibault, 2016/01/13
- [hurd] 24/75: Use -L instead of -Wl,-rpath-link, Samuel Thibault, 2016/01/13
- [hurd] 26/75: libihash: fix fast insertion corner case, Samuel Thibault, 2016/01/13
- [hurd] 25/75: libihash: fix ill-devised locp lookup interface,
Samuel Thibault <=
- [hurd] 21/75: Drop spurious debugging or outdated changes, Samuel Thibault, 2016/01/13
- [hurd] 14/75: Add devnode translator, Samuel Thibault, 2016/01/13
- [hurd] 30/75: ext2fs: improve the block cache, Samuel Thibault, 2016/01/13
- [hurd] 28/75: libihash: fix item insertion, Samuel Thibault, 2016/01/13
- [hurd] 66/75: Make private variables static, Samuel Thibault, 2016/01/13
- [hurd] 32/75: ext2fs: keep list of reusable disk cache entries, Samuel Thibault, 2016/01/13
- [hurd] 33/75: libdiskfs: use ihash for the node cache, Samuel Thibault, 2016/01/13
- [hurd] 31/75: ext2fs: disable block cache debugging by default, Samuel Thibault, 2016/01/13
- [hurd] 27/75: libihash: generalize the interface to support non-integer keys, Samuel Thibault, 2016/01/13
- [hurd] 68/75: Fix build with perl >= 5.22, Samuel Thibault, 2016/01/13