X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fuci.git;a=blobdiff_plain;f=list.c;h=5700605c2d63e727cd6afd6e5e500973e3be7948;hp=b644523bc5760c36e3a4cb8cdc11fc625dcf8153;hb=6042bb553c8660cc649a3f0eed0d932878b10cac;hpb=4094cedb83a0b92a179af13d1781a8fd7d3d943e diff --git a/list.c b/list.c index b644523..5700605 100644 --- a/list.c +++ b/list.c @@ -113,18 +113,18 @@ uci_alloc_section(struct uci_package *p, const char *type, const char *name) { struct uci_context *ctx = p->ctx; struct uci_section *s; - char buf[16]; - if (!name || !name[0]) { - snprintf(buf, 16, "cfg%d", p->n_section); - name = buf; - } + if (name && !name[0]) + name = NULL; s = uci_alloc_element(ctx, section, name, strlen(type) + 1); + uci_list_init(&s->options); s->type = uci_dataptr(s); s->package = p; strcpy(s->type, type); - uci_list_init(&s->options); + if (name == NULL) + s->anonymous = true; + uci_list_add(&p->sections, &s->e.list); return s;