Reinitialize memory pool on each loop of the REPL

This commit is contained in:
Camden Dixie O'Brien 2024-10-24 21:35:25 +01:00
parent e5cd69c26b
commit ecd50c76c5
4 changed files with 2 additions and 8 deletions

View File

@ -19,7 +19,6 @@ static repl_t repl = {
int main(void) int main(void)
{ {
init_repl(&repl);
run_repl(&repl); run_repl(&repl);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View File

@ -22,7 +22,6 @@ typedef struct {
char result_buffer[REPL_RESULT_BUFFER_SIZE]; char result_buffer[REPL_RESULT_BUFFER_SIZE];
} repl_t; } repl_t;
void init_repl(repl_t *repl);
bool step_repl(repl_t *repl); bool step_repl(repl_t *repl);
void run_repl(repl_t *repl); void run_repl(repl_t *repl);

View File

@ -3,13 +3,10 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
void init_repl(repl_t *repl)
{
init_memory_pool(&repl->pool);
}
bool step_repl(repl_t *repl) bool step_repl(repl_t *repl)
{ {
init_memory_pool(&repl->pool);
int len; int len;
for (len = 0; len < REPL_LINE_BUFFER_SIZE; ++len) { for (len = 0; len < REPL_LINE_BUFFER_SIZE; ++len) {
const int byte = repl->get_byte(); const int byte = repl->get_byte();

View File

@ -74,7 +74,6 @@ static void set_up_valid_state(void)
input_len = 14; input_len = 14;
read_result = &expression; read_result = &expression;
evaluate_result = 4321; evaluate_result = 4321;
init_repl(&repl);
} }
static void read_is_called_on_first_line_line_in_input(void) static void read_is_called_on_first_line_line_in_input(void)