+/*
+ * tl-append: time-logger appending shell
+ * Copyright (C) 2023 Scott Worley <scottworley@scottworley.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
#define _POSIX_C_SOURCE 2
#define _XOPEN_SOURCE
#define _GNU_SOURCE
static int is_end(ex_t exp) {
return exp.a == END.a && exp.b == END.b && exp.message == END.message;
}
+static void consume(ex_t *exp) {
+ exp->a = CONSUMED.a;
+ exp->b = CONSUMED.b;
+}
static int is_consumed(ex_t exp) {
- return exp.a == CONSUMED.a && exp.b == CONSUMED.b &&
- exp.message == CONSUMED.message;
+ return exp.a == CONSUMED.a && exp.b == CONSUMED.b;
}
static ex_t expectation(time_t a, time_t b, const char *message) {
ex_t exp;
static void consume_expectation(ex_t exps[], const char *line) {
for (size_t i = 0; !is_end(exps[i]); i++) {
if (line_problem(&exps[i], line) == NULL) {
- exps[i] = CONSUMED;
+ consume(&exps[i]);
return;
}
}
}
results[PARALLELISM] = END;
verify_log_contents_unordered(results);
+ for (int i = 0; i < PARALLELISM; i++) {
+ free((void *)results[i].message);
+ }
}
int main() {