Ruediger Pluem
Tue, 15 Jul 2008 11:43:45 -0700
On 07/15/2008 08:29 AM, [EMAIL PROTECTED] wrote:
Author: mturk Date: Mon Jul 14 23:29:29 2008 New Revision: 676807 URL: http://svn.apache.org/viewvc?rev=676807&view=rev Log: Intruduce apr_hash_do function Modified: apr/apr/trunk/CHANGES apr/apr/trunk/include/apr_hash.h apr/apr/trunk/tables/apr_hash.c
Modified: apr/apr/trunk/tables/apr_hash.c URL: http://svn.apache.org/viewvc/apr/apr/trunk/tables/apr_hash.c?rev=676807&r1=676806&r2=676807&view=diff ============================================================================== --- apr/apr/trunk/tables/apr_hash.c (original) +++ apr/apr/trunk/tables/apr_hash.c Mon Jul 14 23:29:29 2008 @@ -474,4 +474,37 @@ 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)));
Shouldn't we leave the while loop if rv == 0? If not the API promise might not be true, because if the last element returns non zero the return value will be 1 although not all return values were non zero.
+ + if (rv == 0) { + dorv = 0; + }+ } + return dorv;+} +
Regards RĂ¼diger