static int _fr_hash_table_free(fr_hash_table_t *ht)
{
- talloc_free_children(ht);
+ int i;
+ fr_hash_entry_t *node, *next;
+
+ if (ht->free) {
+ for (i = 0; i < ht->num_buckets; i++) {
+ if (ht->buckets[i]) for (node = ht->buckets[i];
+ node != &ht->null;
+ node = next) {
+ next = node->next;
+ if (!node->data) continue; /* dummy entry */
+
+ ht->free(node->data);
+ }
+ }
+ }
+
return 0;
}
return 1;
}
-
-/*
- * Free a hash table
- */
-void fr_hash_table_free(fr_hash_table_t *ht)
-{
- int i;
- fr_hash_entry_t *node, *next;
-
- if (!ht) return;
-
- /*
- * Walk over the buckets, freeing them all.
- */
- if (ht->free) {
- for (i = 0; i < ht->num_buckets; i++) {
- if (ht->buckets[i]) for (node = ht->buckets[i];
- node != &ht->null;
- node = next) {
- next = node->next;
- if (!node->data) continue; /* dummy entry */
-
- ht->free(node->data);
- }
- }
- }
-
- /*
- * Also frees nodes and buckets
- */
- talloc_free(ht);
-}
-
-
/*
* Count number of elements
*/
fr_hash_table_cmp_t cmpNode,
fr_hash_table_free_t freeNode);
-void fr_hash_table_free(fr_hash_table_t *ht);
-
int fr_hash_table_insert(fr_hash_table_t *ht, void const *data);
int fr_hash_table_delete(fr_hash_table_t *ht, void const *data);
{ NULL }
};
-/*
- * Clean up.
- */
-static int mod_detach(void *instance)
-{
- rlm_detail_t *inst = instance;
-
- if (inst->ht) fr_hash_table_free(inst->ht);
- return 0;
-}
-
-
static uint32_t detail_hash(void const *data)
{
fr_dict_attr_t const *da = data;
if (cs) {
CONF_ITEM *ci;
- inst->ht = fr_hash_table_create(NULL, detail_hash, detail_cmp, NULL);
+ inst->ht = fr_hash_table_create(inst, detail_hash, detail_cmp, NULL);
for (ci = cf_item_next(cs, NULL);
ci != NULL;
* If we didn't suppress anything, delete the hash table.
*/
if (fr_hash_table_num_elements(inst->ht) == 0) {
- fr_hash_table_free(inst->ht);
- inst->ht = NULL;
+ TALLOC_FREE(inst->ht);
+ } else {
+ fr_hash_table_fill(inst->ht);
}
}
.inst_size = sizeof(rlm_detail_t),
.config = module_config,
.instantiate = mod_instantiate,
- .detach = mod_detach,
.methods = {
[MOD_AUTHORIZE] = mod_authorize,
[MOD_PREACCT] = mod_accounting,