for use with if (0) { ... }, so that unused xlats can be freed.
Otherwise they're stuck in the instantiation tree, and will cause
issues.
}
}
}
+
+/*
+ * Used when we don't need the children any more, as with
+ *
+ * if (0) { ... }
+ */
+void cf_item_free_children(CONF_ITEM *ci)
+{
+ fr_dlist_talloc_free(&ci->children);
+ TALLOC_FREE(ci->ident1);
+ TALLOC_FREE(ci->ident2);
+}
#define cf_lineno_set(_ci, _lineno) _cf_lineno_set(CF_TO_ITEM(_ci), _lineno)
void _cf_lineno_set(CONF_ITEM *cs, int lineno);
+void cf_item_free_children(CONF_ITEM *ci);
+
/*
* Section manipulation and searching
*/
fr_token_t cf_section_name2_quote(CONF_SECTION const *cs);
fr_token_t cf_section_argv_quote(CONF_SECTION const *cs, int argc);
+#define cf_section_free_children(_x) cf_item_free_children(cf_section_to_item(_x))
+
+
/*
* Pair manipulation and searching
*/
cf_log_debug_prefix(cs, "Skipping contents of '%s' as it is always 'false'",
unlang_ops[ext->type].name);
- c = compile_section(parent, unlang_ctx, cs, ext);
- talloc_free(c);
-
+ /*
+ * Free the children, which frees any xlats,
+ * conditions, etc. which were defined, but are
+ * now entirely unused.
+ */
+ cf_section_free_children(cs);
c = compile_empty(parent, unlang_ctx, cs, ext);
} else {