const void *table,
bool relaxed,
bool allow_include,
+ bool warn,
void *userdata);
/* Generic parsers */
void *data, \
void *userdata) { \
\
- type **enums = data, *xs, x, *ys; \
- char *w, *state; \
+ type **enums = data, x, *ys; \
+ _cleanup_free_ type *xs = NULL; \
+ const char *word, *state; \
size_t l, i = 0; \
\
assert(filename); \
assert(data); \
\
xs = new0(type, 1); \
+ if(!xs) \
+ return -ENOMEM; \
+ \
*xs = invalid; \
\
- FOREACH_WORD(w, l, rvalue, state) { \
+ FOREACH_WORD(word, l, rvalue, state) { \
_cleanup_free_ char *en = NULL; \
+ type *new_xs; \
\
- en = strndup(w, l); \
+ en = strndup(word, l); \
if (!en) \
return -ENOMEM; \
\
continue; \
\
*(xs + i) = x; \
- xs = realloc(xs, (++i + 1) * sizeof(type)); \
- if (!xs) \
+ new_xs = realloc(xs, (++i + 1) * sizeof(type)); \
+ if (new_xs) \
+ xs = new_xs; \
+ else \
return -ENOMEM; \
+ \
*(xs + i) = invalid; \
} \
\
free(*enums); \
*enums = xs; \
+ xs = NULL; \
+ \
return 0; \
}