summaryrefslogtreecommitdiff
path: root/tables
diff options
context:
space:
mode:
authorMladen Turk <mturk@apache.org>2008-07-15 06:29:29 +0000
committerMladen Turk <mturk@apache.org>2008-07-15 06:29:29 +0000
commit1f5f86b8ec23241b49f65ff4aa6466d2ba628878 (patch)
tree901339d4bbf4f7a3c288f239d0f0e25596c41e45 /tables
parent74a942269cf07107ee27382dbf2658463ea518be (diff)
downloadapr-1f5f86b8ec23241b49f65ff4aa6466d2ba628878.tar.gz
Intruduce apr_hash_do function
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@676807 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'tables')
-rw-r--r--tables/apr_hash.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/tables/apr_hash.c b/tables/apr_hash.c
index 4e3723e19..6f30b68fc 100644
--- a/tables/apr_hash.c
+++ b/tables/apr_hash.c
@@ -474,4 +474,37 @@ APR_DECLARE(apr_hash_t *) apr_hash_merge(apr_pool_t *p,
return res;
}
+/* This is basically the following...
+ * for every element in hash table {
+ * comp elemeny.key, element.value
+ * }
+ *
+ * Like with apr_table_do, the comp callback is called for each and every
+ * element of the hash table.
+ */
+APR_DECLARE(int) apr_hash_do(apr_hash_do_callback_fn_t *comp,
+ void *rec, const apr_hash_t *ht)
+{
+ apr_hash_index_t hix;
+ apr_hash_index_t *hi;
+ int rv, dorv = 1;
+
+ hix.ht = (apr_hash_t *)ht;
+ hix.index = 0;
+ hix.this = NULL;
+ hix.next = NULL;
+
+ if ((hi = apr_hash_next(&hix))) {
+ /* Scan the entire table */
+ do {
+ rv = (*comp)(rec, hi->this->key, hi->this->klen, hi->this->val);
+ } while ((hi = apr_hash_next(hi)));
+
+ if (rv == 0) {
+ dorv = 0;
+ }
+ }
+ return dorv;
+}
+
APR_POOL_IMPLEMENT_ACCESSOR(hash)