From ecd50c76c5fc453f50d6630f616ba9c4266973d4 Mon Sep 17 00:00:00 2001 From: Camden Dixie O'Brien Date: Thu, 24 Oct 2024 21:35:25 +0100 Subject: [PATCH] Reinitialize memory pool on each loop of the REPL --- app/main.c | 1 - lib/include/repl.h | 1 - lib/repl.c | 7 ++----- tests/repl_tests.c | 1 - 4 files changed, 2 insertions(+), 8 deletions(-) diff --git a/app/main.c b/app/main.c index 8ae2915..690a5b3 100644 --- a/app/main.c +++ b/app/main.c @@ -19,7 +19,6 @@ static repl_t repl = { int main(void) { - init_repl(&repl); run_repl(&repl); return EXIT_SUCCESS; } diff --git a/lib/include/repl.h b/lib/include/repl.h index 908ec0a..7a99b8c 100644 --- a/lib/include/repl.h +++ b/lib/include/repl.h @@ -22,7 +22,6 @@ typedef struct { char result_buffer[REPL_RESULT_BUFFER_SIZE]; } repl_t; -void init_repl(repl_t *repl); bool step_repl(repl_t *repl); void run_repl(repl_t *repl); diff --git a/lib/repl.c b/lib/repl.c index 18dad2f..af3e77c 100644 --- a/lib/repl.c +++ b/lib/repl.c @@ -3,13 +3,10 @@ #include #include -void init_repl(repl_t *repl) -{ - init_memory_pool(&repl->pool); -} - bool step_repl(repl_t *repl) { + init_memory_pool(&repl->pool); + int len; for (len = 0; len < REPL_LINE_BUFFER_SIZE; ++len) { const int byte = repl->get_byte(); diff --git a/tests/repl_tests.c b/tests/repl_tests.c index 1306ba2..69d39a1 100644 --- a/tests/repl_tests.c +++ b/tests/repl_tests.c @@ -74,7 +74,6 @@ static void set_up_valid_state(void) input_len = 14; read_result = &expression; evaluate_result = 4321; - init_repl(&repl); } static void read_is_called_on_first_line_line_in_input(void)