diff options
author | Justus Winter <4winter@informatik.uni-hamburg.de> | 2015-11-21 16:12:53 +0100 |
---|---|---|
committer | Justus Winter <4winter@informatik.uni-hamburg.de> | 2015-11-29 23:57:55 +0100 |
commit | e6fdb474b7fc4237b19d8405074930518ac02b27 (patch) | |
tree | 44832f3f0d08ce066cd50b4bda6e3e524c0fc3b9 /libihash/ihash.c | |
parent | c9c29eb890527fe68900e4a0af7c2df9a9fa5b40 (diff) |
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.
Diffstat (limited to 'libihash/ihash.c')
-rw-r--r-- | libihash/ihash.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/libihash/ihash.c b/libihash/ihash.c index 87d7abf4..8b1ad1f8 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; } |