summaryrefslogtreecommitdiff
path: root/src/interpreter.c
diff options
context:
space:
mode:
authorTyler Murphy <tylerm@tylerm.dev>2023-04-13 19:27:20 -0400
committerTyler Murphy <tylerm@tylerm.dev>2023-04-13 19:27:20 -0400
commitb4b00cb6d2a3aa4ca6981e869b96af195c861dd3 (patch)
tree49c5d66b7f041234a5725d22b0fc98007834b917 /src/interpreter.c
parentuh funny forget to free things (diff)
downloadbrainfucked-b4b00cb6d2a3aa4ca6981e869b96af195c861dd3.tar.gz
brainfucked-b4b00cb6d2a3aa4ca6981e869b96af195c861dd3.tar.bz2
brainfucked-b4b00cb6d2a3aa4ca6981e869b96af195c861dd3.zip
fix the thing with the thing
Diffstat (limited to '')
-rw-r--r--src/interpreter.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/interpreter.c b/src/interpreter.c
index 2f9ae76..7255a4c 100644
--- a/src/interpreter.c
+++ b/src/interpreter.c
@@ -52,6 +52,20 @@ static void recurse_program(Program* program, Tape* tape) {
next:
program_next(program, &s);
+ // printf("[");
+ // for(uint32_t i = 0; i < tape->len; i++) {
+ // printf("0x%02x ", tape->data[i]);
+ // }
+ // printf("\b]\n ");
+ // for(uint32_t i = 0; i < tape->len; i++) {
+ // if (i == tape->index) {
+ // printf(" ^ ");
+ // } else {
+ // printf(" ");
+ // }
+ // }
+ // printf(" \ + tape->indexn");
+
switch (s) {
case MoveLeft:
tape_left(tape);
@@ -85,7 +99,7 @@ next:
case Allocate: {
uint8_t len = tape_get(tape);
Tape* new = malloc(sizeof(Tape));
- tape_init(len, tape);
+ tape_init(len, new);
void* ptr = (void*) tape_ptr(tape);
memcpy(ptr, &new, sizeof(Tape*));
break;