funny valgrind

This commit is contained in:
Murphy 2023-04-13 22:24:28 -04:00
parent ae48fca094
commit d067119a90
3 changed files with 5 additions and 10 deletions

View file

@ -136,7 +136,6 @@ next:
break;
case LeaveTape:
case Eof:
case Invalid:
return;
}

View file

@ -64,7 +64,8 @@ retest:
case EOF:
return Eof;
default:
return Invalid;
c = next_char();
goto retest;
}
}
@ -80,16 +81,12 @@ void program_init(char* file_path, Program* program) {
program->data = malloc(capacity * sizeof(Symbol));
program->len = 0;
program->index = 0;
Symbol s;
while(true) {
s = next_symbol();
if (s == Invalid) {
printf("error: invalid symbol at character %d\n", count);
exit(EXIT_FAILURE);
}
if (program->len == capacity) {
capacity *= 2;
program->data = realloc(program->data, capacity * sizeof(Symbol));
@ -118,7 +115,7 @@ void program_next(Program* program, Symbol* symbol) {
}
void program_last(Program* program, Symbol* symbol) {
if (program->index == 0) {
if (program->index < 1) {
*symbol = Eof;
return;
}

View file

@ -19,8 +19,7 @@ typedef enum {
PutString,
GetString,
Clear,
Eof,
Invalid
Eof
} Symbol;
typedef struct {