aoc-2022/day_1/state.c
2022-12-25 21:15:50 +01:00

15 lines
375 B
C

#include <stdlib.h>
struct parser_state {
unsigned tmp_val;
unsigned* calorie_list;
size_t size;
};
void push_value(struct parser_state* state) {
// TODO(feliix42): error handling here?
state->calorie_list = realloc(state->calorie_list, state->size+1);
state->calorie_list[state->size] = state->tmp_val;
state->tmp_val = 0;
state->size++;
}