* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * GNU Lesser General Public License for more details.
*/
/*
- * This file contains ucimap, an API for mapping UCI to C data structures
+ * This file contains ucimap, an API for mapping UCI to C data structures
*/
#include <strings.h>
void
ucimap_cleanup(struct uci_map *map)
{
- struct ucimap_section_data *sd;
+ struct ucimap_section_data *sd, *sd_next;
- for (sd = map->sdata; sd; sd = sd->next) {
+ for (sd = map->sdata; sd; sd = sd_next) {
+ sd_next = sd->next;
ucimap_free_section(map, sd);
}
}
if (!*list) {
new = calloc(1, size);
+ if (!new)
+ return -ENOMEM;
ucimap_add_alloc(sd, new);
goto set;
offset = (items - (*list)->size) * sizeof(union ucimap_data);
a->ptr = realloc(a->ptr, size);
+ if (!a->ptr)
+ return -ENOMEM;
+
if (offset)
memset((char *) a->ptr + offset, 0, size - offset);
new = a->ptr;
struct ucimap_fixup *f, tmp;
struct uci_map *map = sd->map;
+ tmp.next = NULL;
tmp.sm = om->data.sm;
tmp.name = str;
tmp.type = om->type;
return 0;
error_mem:
- if (sd->allocmap)
- free(sd->allocmap);
+ free(sd->alloc_custom);
+ free(sd->allocmap);
free(sd);
return UCI_ERR_MEM;