[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 51/70: libihash: add HURD_IHASH_ITERATE_ITEMS macro
From: |
Samuel Thibault |
Subject: |
[hurd] 51/70: libihash: add HURD_IHASH_ITERATE_ITEMS macro |
Date: |
Mon, 16 Sep 2013 07:41:44 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch upstream
in repository hurd.
commit 39e97c785a7b7f5fd5458986aa834e4069ce3b2f
Author: Justus Winter <address@hidden>
Date: Thu Sep 5 18:38:39 2013 +0200
libihash: add HURD_IHASH_ITERATE_ITEMS macro
Add a macro HURD_IHASH_ITERATE_ITEMS that iterates over all elements
in the hash table making both the key and the value available.
* libihash/ihash.h (HURD_IHASH_ITERATE_ITEMS): New macro.
---
libihash/ihash.h | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/libihash/ihash.h b/libihash/ihash.h
index a4e76dc..3ca5ec3 100644
--- a/libihash/ihash.h
+++ b/libihash/ihash.h
@@ -218,6 +218,23 @@ hurd_ihash_value_t hurd_ihash_find (hurd_ihash_t ht,
hurd_ihash_key_t key);
(((_hurd_ihash_item_t) _hurd_ihash_valuep) + 1)) \
if (val != _HURD_IHASH_EMPTY && val != _HURD_IHASH_DELETED)
+/* Iterate over all elements in the hash table making both the key and
+ the value available. You use this macro with a block, for example
+ like this:
+
+ HURD_IHASH_ITERATE_ITEMS (ht, item)
+ foo (item->key, item->value);
+
+ The block will be run for every element in the hash table HT. The
+ key and value of the current element is available as ITEM->key and
+ ITEM->value. */
+#define HURD_IHASH_ITERATE_ITEMS(ht, item) \
+ for (_hurd_ihash_item_t item = (ht)->size? &(ht)->items[0]: 0; \
+ (ht)->size && item - &(ht)->items[0] < (ht)->size; \
+ item++) \
+ if (item->value != _HURD_IHASH_EMPTY && \
+ item->value != _HURD_IHASH_DELETED)
+
/* Remove the entry with the key KEY from the hash table HT. If such
an entry was found and removed, 1 is returned, otherwise 0. */
int hurd_ihash_remove (hurd_ihash_t ht, hurd_ihash_key_t key);
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] 64/70: hurd: add fsys_get_source, (continued)
- [hurd] 64/70: hurd: add fsys_get_source, Samuel Thibault, 2013/09/16
- [hurd] 59/70: hurd: add fsys_get_children, Samuel Thibault, 2013/09/16
- [hurd] 68/70: Handle notification on page eviction, Samuel Thibault, 2013/09/16
- [hurd] 65/70: trans: add mtab translator, Samuel Thibault, 2013/09/16
- [hurd] 49/70: proc: remove unused file exc-reply.defs, Samuel Thibault, 2013/09/16
- [hurd] 47/70: hurd: add proc_{get,set}_code, Samuel Thibault, 2013/09/16
- [hurd] 44/70: mount: handle -t auto, Samuel Thibault, 2013/09/16
- [hurd] 55/70: libdiskfs: add fsys_get_children, Samuel Thibault, 2013/09/16
- [hurd] 18/70: libshouldbeinlibc: Add nullauth.{c,h}, Samuel Thibault, 2013/09/16
- [hurd] 39/70: libnetfs: register libnetfs-based translators as important, Samuel Thibault, 2013/09/16
- [hurd] 51/70: libihash: add HURD_IHASH_ITERATE_ITEMS macro,
Samuel Thibault <=
- [hurd] 15/70: Define and use symbolic names for important processes, Samuel Thibault, 2013/09/16
- [hurd] 52/70: libdiskfs: track file name in struct peropen, Samuel Thibault, 2013/09/16
- [hurd] 50/70: proc: Remove unused declaration of zombie_list, Samuel Thibault, 2013/09/16
- [hurd] 31/70: Merge branch 'master-merge2' into master-merge, Samuel Thibault, 2013/09/16
- [hurd] 12/70: umount: add a umount utility, Samuel Thibault, 2013/09/16
- [hurd] 10/70: sutils: allow multiple entries for the device "none", Samuel Thibault, 2013/09/16
- [hurd] 08/70: mount: implement -O, --test-opts, Samuel Thibault, 2013/09/16
- [hurd] 07/70: mount: add -f and --fake arguments, Samuel Thibault, 2013/09/16
- [hurd] 11/70: sutils: fix the semantic of -t, --types in fstab.c, Samuel Thibault, 2013/09/16
- [hurd] 42/70: trans: register symlink translators as important, Samuel Thibault, 2013/09/16