- struct uci_section *section = NULL;
- struct uci_context *ctx = cfg->ctx;
-
- UCI_TRAP_SAVE(ctx, error);
- section = (struct uci_section *) uci_malloc(ctx, sizeof(struct uci_section));
- section->config = cfg;
- uci_list_init(§ion->list);
- uci_list_init(§ion->options);
- section->type = uci_strdup(ctx, type);
- if (name)
- section->name = uci_strdup(ctx, name);
- uci_list_add(&cfg->sections, §ion->list);
- UCI_TRAP_RESTORE(ctx);
-
- return section;
-
-error:
- uci_drop_section(section);
- UCI_THROW(ctx, ctx->errno);
- return NULL;
+ struct uci_element *o, *tmp;
+
+ uci_foreach_element_safe(&s->options, tmp, o) {
+ uci_free_option(uci_to_option(o));
+ }
+ uci_free_element(&s->e);