Fix TODO on day 1
This commit is contained in:
parent
9354fb17cc
commit
e25d9e0a43
1 changed files with 6 additions and 2 deletions
|
@ -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++;
|
||||||
|
|
Loading…
Reference in a new issue