remove internal usage of redundant uci_ptr.last
[project/uci.git] / ucimap.c
index 7c2b0435d308358c83cfa89d7f14133ad4dca008..758a5eabda266149e08a52c5f85872156e65b91c 100644 (file)
--- a/ucimap.c
+++ b/ucimap.c
@@ -661,11 +661,10 @@ ucimap_parse_section(struct uci_map *map, struct uci_sectionmap *sm, struct ucim
                        size = sizeof(struct ucimap_list) +
                                n_elements * sizeof(union ucimap_data);
 
-                       data->list = malloc(size);
+                       data->list = calloc(1, size);
                        if (!data->list)
                                goto error_mem;
 
-                       memset(data->list, 0, size);
                        data->list->size = n_elements;
                } else {
                        ucimap_count_alloc(om, &n_alloc, &n_alloc_custom);
@@ -893,14 +892,15 @@ ucimap_parse(struct uci_map *map, struct uci_package *pkg)
 
                        if (sm->alloc) {
                                sd = sm->alloc(map, sm, s);
+                               if (!sd)
+                                       continue;
                                memset(sd, 0, sizeof(struct ucimap_section_data));
                        } else {
-                               sd = malloc(sm->alloc_len);
-                               memset(sd, 0, sm->alloc_len);
+                               sd = calloc(1, sm->alloc_len);
+                               if (!sd)
+                                       continue;
                                sd = ucimap_ptr_section(sm, sd);
                        }
-                       if (!sd)
-                               continue;
 
                        ucimap_parse_section(map, sm, sd, s);
                }