void config_destroy(config_t *config) { unsigned int count = config->num_filenames; const char **f; __config_setting_destroy(config->root); for(f = config->filenames; count > 0; ++f, --count) _delete(*f); _delete(config->filenames); memset((void *)config, 0, sizeof(config_t)); }
static void __config_list_destroy(config_list_t *list) { config_setting_t **p; unsigned int i; if(! list) return; if(list->elements) { for(p = list->elements, i = 0; i < list->length; p++, i++) __config_setting_destroy(*p); _delete(list->elements); } _delete(list); }
int config_setting_remove(config_setting_t *parent, const char *name) { unsigned int idx; config_setting_t *setting; if(! parent) return(CONFIG_FALSE); if(parent->type != CONFIG_TYPE_GROUP) return(CONFIG_FALSE); if(! (setting = __config_list_search(parent->value.list, name, &idx))) return(CONFIG_FALSE); __config_list_remove(parent->value.list, idx); __config_setting_destroy(setting); return(CONFIG_TRUE); }
int config_setting_remove_elem (config_setting_t * parent, unsigned int idx) { config_list_t *list; config_setting_t *removed = NULL; if (!parent) return (CONFIG_FALSE); list = parent->value.list; if (((parent->type != CONFIG_TYPE_ARRAY) && (parent->type != CONFIG_TYPE_LIST) && (parent->type != CONFIG_TYPE_GROUP)) || !list) return (CONFIG_FALSE); if (idx >= list->length) return (CONFIG_FALSE); removed = __config_list_remove (list, idx); __config_setting_destroy (removed); return (CONFIG_TRUE); }
void config_destroy(config_t *config) { __config_setting_destroy(config->root); memset((void *)config, 0, sizeof(config_t)); }