* linked compenents anyway. */
#define CALENDARSPEC_COMPONENTS_MAX 240
-static void free_chain(CalendarComponent *c) {
+static void chain_free(CalendarComponent *c) {
CalendarComponent *n;
while (c) {
if (!c)
return NULL;
- free_chain(c->year);
- free_chain(c->month);
- free_chain(c->day);
- free_chain(c->hour);
- free_chain(c->minute);
- free_chain(c->microsecond);
+ chain_free(c->year);
+ chain_free(c->month);
+ chain_free(c->day);
+ chain_free(c->hour);
+ chain_free(c->minute);
+ chain_free(c->microsecond);
free(c->timezone);
return mfree(c);
}
static int calendarspec_from_time_t(CalendarSpec *c, time_t time) {
+ _cleanup_CalendarComponent *year = NULL, *month = NULL, *day = NULL, *hour = NULL, *minute = NULL, *us = NULL;
struct tm tm;
- CalendarComponent *year = NULL, *month = NULL, *day = NULL, *hour = NULL, *minute = NULL, *us = NULL;
int r;
if (!gmtime_r(&time, &tm))
r = prepend_component(&t, usec, 0, &cc);
if (r < 0) {
- free_chain(cc);
+ chain_free(cc);
return r;
}
/* Already the end? A ':' as separator? In that case this was a time, not a date */
if (IN_SET(*t, 0, ':')) {
- free_chain(first);
+ chain_free(first);
return 0;
}
if (*t == '~')
c->end_of_month = true;
else if (*t != '-') {
- free_chain(first);
+ chain_free(first);
return -EINVAL;
}
t++;
r = parse_chain(&t, false, &second);
if (r < 0) {
- free_chain(first);
+ chain_free(first);
return r;
}
c->day = second;
return 0;
} else if (c->end_of_month) {
- free_chain(first);
- free_chain(second);
+ chain_free(first);
+ chain_free(second);
return -EINVAL;
}
if (*t == '~')
c->end_of_month = true;
else if (*t != '-') {
- free_chain(first);
- free_chain(second);
+ chain_free(first);
+ chain_free(second);
return -EINVAL;
}
t++;
r = parse_chain(&t, false, &third);
if (r < 0) {
- free_chain(first);
- free_chain(second);
+ chain_free(first);
+ chain_free(second);
return r;
}
return 0;
}
- free_chain(first);
- free_chain(second);
- free_chain(third);
+ chain_free(first);
+ chain_free(second);
+ chain_free(third);
return -EINVAL;
}
return 0;
fail:
- free_chain(h);
- free_chain(m);
- free_chain(s);
+ chain_free(h);
+ chain_free(m);
+ chain_free(s);
return r;
}