@@ -178,22 +178,18 @@ void xlu__cfg_value_free(XLU_ConfigValue *value)
}
void xlu__cfg_set_free(XLU_ConfigSetting *set) {
- if (!set) return;
- free(set->name);
- xlu__cfg_value_free(set->value);
- free(set);
+ while(set) {
+ XLU_ConfigSetting *next = set->next;
+ free(set->name);
+ xlu__cfg_value_free(set->value);
+ free(set);
+ set = next;
+ }
}
void xlu_cfg_destroy(XLU_Config *cfg) {
- XLU_ConfigSetting *set, *set_next;
-
if (!cfg) return;
- for (set= cfg->settings;
- set;
- set= set_next) {
- set_next= set->next;
- xlu__cfg_set_free(set);
- }
+ xlu__cfg_set_free(cfg->settings);
free((void *)cfg->config_source);
free(cfg);
}
@@ -32,7 +32,6 @@ enum XLU_Operation {
XLU_OP_ADDITION,
};
-void xlu__cfg_set_free(XLU_ConfigSetting *set);
void xlu__cfg_set_store(CfgParseContext*, char *name,
enum XLU_Operation op,
XLU_ConfigValue *val, int lineno);
@@ -35,6 +35,11 @@ typedef struct XLU_ConfigSetting XLU_ConfigSetting;
extern int xlu_cfg_printf(const XLU_Config *cfg, const char *format, ...)
__attribute__((__format__(__printf__, 2, 3)));
+/*
+ * Internals for file parser *only*, NOT to be used by other parsing/lexing
+ */
+extern void xlu__cfg_set_free(XLU_ConfigSetting *set);
+
#endif /*LIBXLU_INTERNAL_H*/
/*
This better breaks layers apart. xlu_cfg_destroy() now only knows about the XLU_Config structure, while xlu__cfg_set_free() knows about XLU_ConfigSetting. Move declaration of xlu__cfg_set_free() to shared header to indicate it will bridge layers. Signed-off-by: Elliott Mitchell <ehem+xen@m5p.com> --- This is the end of the higher-value series. Moving the loop is appropriate whether or not libxlu_cfg.c is split. Moving the declaration and patches after this though are mostly valuable for splitting libxlu_cfg.c into reusable and non-reusable portions. --- tools/libs/util/libxlu_cfg.c | 20 ++++++++------------ tools/libs/util/libxlu_cfg_y.y | 1 - tools/libs/util/libxlu_internal.h | 5 +++++ 3 files changed, 13 insertions(+), 13 deletions(-)