Fix TODO on day 1

This commit is contained in:
Felix Suchert 2022-12-25 23:38:20 +01:00
parent 9354fb17cc
commit e25d9e0a43
Signed by: feliix42
GPG key ID: 24363525EA0E8A99

View file

@ -23,8 +23,12 @@
#include "lexer.h" #include "lexer.h"
void push_value(struct parser_state* state) { void push_value(struct parser_state* state) {
// TODO(feliix42): error handling here? unsigned long* resized = realloc(state->calorie_list, (state->size+1) * sizeof(unsigned long));
state->calorie_list = realloc(state->calorie_list, (state->size+1) * sizeof(unsigned long)); if (!resized) {
fprintf(stderr, "\033[93m[error] Failed to allocate enough memory to resize the list of calories\033[0m\n");
return;
}
state->calorie_list = resized;
state->calorie_list[state->size] = state->tmp_val; state->calorie_list[state->size] = state->tmp_val;
state->tmp_val = 0; state->tmp_val = 0;
state->size++; state->size++;