[RFC] Simplify use of apr_hash_this()
From: Julian Foad <julianfoad_at_btopenworld.com>
Date: Tue, 30 Jun 2009 13:05:50 +0100
I propose a new macro to simplify the use of apr_hash_this().
To de-reference an APR hash iterator, we want to write something like:
for (hi = apr_hash_first(pool, entries); hi; hi = apr_hash_next(hi))
apr_hash_this(hi, &item, NULL, &entry);
...
But to avoid warnings or errors to do with pointer type conversions,
for (hi = apr_hash_first(pool, entries); hi; hi = apr_hash_next(hi))
apr_hash_this(hi, &key, NULL, &val);
item = key;
...
which is what we normally do, or add explicit type casts:
for (hi = apr_hash_first(pool, entries); hi; hi = apr_hash_next(hi))
apr_hash_this(hi, (void *)&item, NULL, (void *)&entry);
...
Whether such type casts make a detectable difference depends on what
The attached patch "apr_hash_this-def.patch" allows us to write it as I
The second attached patch "apr_hash_this-use.patch" demonstrates the use
To me, this will enable a big improvement in code clarity. Anything
(The attached patch contains two alternative implementations, and I
- Julian
------------------------------------------------------
|
This is an archived mail posted to the Subversion Dev mailing list.
This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.