From 5f91b656bce8700bfe6d1a3faf5e4c5d64bcc84d Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Mon, 21 Apr 2014 16:53:55 -0400 Subject: [PATCH] codesize flag now tracks number of bytecodes in the command and comma now uses/updates this when appending a bytecode --- source/slvm/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/slvm/main.c b/source/slvm/main.c index 93c28c6..78de551 100644 --- a/source/slvm/main.c +++ b/source/slvm/main.c @@ -260,7 +260,7 @@ defcode("create", create, 0, 0, &rbrack){ /* Initialize the flags (hidden and non-immediate by default) */ word->flags.f_immed = 0; word->flags.f_hidden = 1; - word->flags.codesize = 0; + word->flags.codesize = 1; /* Initialize the name, codeword, and bytecode */ word->name = name; word->codeword = &docolon; @@ -280,8 +280,8 @@ defcode(",", comma, 0, 0, &create){ *((long*)here_val) = *(ArgStackPtr); ArgStackPtr--; /* Resize the code section and relocate if necessary */ - long currsize = sizeof(long) + (here_val - (long)word->code); - word->code = (long*)realloc(word->code, currsize + sizeof(long)); + word->flags.codesize++; + word->code = (long*)realloc(word->code, word->flags.codesize * sizeof(long)); /* Update "here" and terminate the code section */ here_val = (long)(((long*)here_val) + 1); *((long*)here_val) = (long)&ret; -- 2.52.0