21 afw_associative_array_add_reference_value_cb add_reference_value;
23 afw_associative_array_release_value_cb release_value;
37 afw_associative_array_create(
38 afw_associative_array_add_reference_value_cb add_reference_value,
39 afw_associative_array_release_value_cb release_value,
51 self->reference_count = 1;
52 self->add_reference_value = add_reference_value;
53 self->release_value = release_value;
60 if ((add_reference_value && !release_value) ||
61 (release_value && !add_reference_value))
64 "If either add_reference_value or release_value is specified, "
65 "both must be specified.",
76 afw_associative_array_release (
90 if (self->release_value) {
91 for (hi = apr_hash_first(
94 hi = apr_hash_next(hi))
96 apr_hash_this(hi, &key, &klen, (
void **)&value);
97 self->release_value(value, xctx);
110 afw_associative_array_add_reference (
122 impl_release_value(
void *data,
void *data2,
125 afw_associative_array_release_value_cb cb = data2;
136 afw_associative_array_get (
144 value = apr_hash_get(self->values, key->s, key->len);
150 if (value && self->add_reference_value) {
151 self->add_reference_value(value, xctx);
153 impl_release_value, xctx);
166 afw_associative_array_get_reference(
174 value = apr_hash_get(self->values, key->s, key->len);
177 if (value && self->add_reference_value) {
178 self->add_reference_value(value, xctx);
191 afw_associative_array_for_each(
196 apr_hash_index_t *hi;
201 hi = apr_hash_next(hi))
203 apr_hash_this(hi, NULL, NULL, (
void **)&value);
204 if (callback(value, context, xctx)) {
209 callback(NULL, context, xctx);
218 afw_associative_array_set(
223 const void *existing;
226 existing = apr_hash_get(self->values, key->s, key->len);
227 if (existing && self->release_value) {
228 self->release_value(existing, xctx);
232 if (value && self->add_reference_value) {
233 self->add_reference_value(value, xctx);
237 apr_hash_set(self->values, key->s, key->len, value);
AFW_DEFINE(const afw_object_t *)
Adaptive Framework Core Internal.
afw_integer_t afw_atomic_integer_decrement(AFW_ATOMIC afw_integer_t *mem)
Integer atomic decrement.
afw_integer_t afw_atomic_integer_increment(AFW_ATOMIC afw_integer_t *mem)
Integer atomic increment.
afw_boolean_t(* afw_value_cb_t)(const void *value, void *context, afw_xctx_t *xctx)
Typedef for value callback.
apr_int64_t afw_integer_t
typedef for big signed int.
#define AFW_THROW_ERROR_Z(code, message_z, xctx)
Macro used to set error and 0 rv in xctx and throw it.
#define afw_pool_get_apr_pool(instance)
Call method get_apr_pool of interface afw_pool.
#define afw_pool_release(instance, xctx)
Call method release of interface afw_pool.
#define afw_pool_register_cleanup_before(instance, data, data2, cleanup, xctx)
Call method register_cleanup_before of interface afw_pool.
#define afw_pool_calloc_type(instance, type, xctx)
Macro to allocate cleared memory to hold type in pool.
const afw_pool_t * afw_pool_create(const afw_pool_t *parent, afw_xctx_t *xctx)
Create a new pool.
Interface afw_object public struct.
Interface afw_pool public struct.
NFC normalized UTF-8 string.
Interface afw_xctx public struct.