diff options
author | mturk <mturk@13f79535-47bb-0310-9956-ffa450edef68> | 2008-07-15 06:29:29 +0000 |
---|---|---|
committer | mturk <mturk@13f79535-47bb-0310-9956-ffa450edef68> | 2008-07-15 06:29:29 +0000 |
commit | 852001ca217bd9786d0029bea8894b1be890c976 (patch) | |
tree | 901339d4bbf4f7a3c288f239d0f0e25596c41e45 /tables/apr_hash.c | |
parent | a82ea188977fbcfc6f106f6c5c226e0d73bf7637 (diff) | |
download | libapr-852001ca217bd9786d0029bea8894b1be890c976.tar.gz |
Intruduce apr_hash_do function
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@676807 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'tables/apr_hash.c')
-rw-r--r-- | tables/apr_hash.c | 33 |
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) |