section = (unsigned long) sd + sizeof(struct uci_sectmap_data);
uci_foreach_element(&s->options, e) {
struct uci_optmap *om = NULL;
+ void *ptr = sm->options;
+ int size = sm->options_size;
+
+ if (!size)
+ size = sizeof(struct uci_optmap);
for (i = 0; i < sm->n_options; i++) {
- if (strcmp(e->name, sm->options[i].name) == 0) {
- om = &sm->options[i];
+ struct uci_optmap *tmp = ptr;
+
+ if (strcmp(e->name, tmp->name) == 0) {
+ om = ptr;
break;
}
+ ptr = (unsigned char *)ptr + size;
}
if (!om)
continue;
{
struct uci_sectmap_data *sd = NULL;
void *section = NULL;
+ char *section_name;
int err;
sd = malloc(sm->alloc_len + sizeof(struct uci_sectmap_data));
if (!sd->allocmap)
goto error_mem;
- sd->section_name = strdup(s->e.name);
- if (!sd->section_name)
+ section_name = strdup(s->e.name);
+ if (!section_name)
goto error_mem;
+ sd->section_name = section_name;
+
sd->cmap = malloc(BITFIELD_SIZE(sm->n_options));
if (!sd->cmap)
goto error_mem;
memset(sd->cmap, 0, BITFIELD_SIZE(sm->n_options));
- ucimap_add_alloc(&sd->allocmap[sd->allocmap_len++], (void *)sd->section_name);
+ ucimap_add_alloc(&sd->allocmap[sd->allocmap_len++], (void *)section_name);
ucimap_add_alloc(&sd->allocmap[sd->allocmap_len++], (void *)sd->cmap);
section = (char *)sd + sizeof(struct uci_sectmap_data);