+ char buf[16];
+
+ if (!name || !name[0]) {
+ snprintf(buf, 16, "cfg%d", p->n_section);
+ name = buf;
+ }
+
+ s = uci_alloc_element(ctx, section, name, strlen(type) + 1);
+ s->type = uci_dataptr(s);
+ s->package = p;
+ strcpy(s->type, type);
+ uci_list_init(&s->options);
+ uci_list_add(&p->sections, &s->e.list);
+
+ return s;
+}
+
+static void
+uci_free_section(struct uci_section *s)
+{
+ 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);
+}
+
+static struct uci_package *
+uci_alloc_package(struct uci_context *ctx, const char *name)
+{
+ struct uci_package *p;