From e1f32dc31f66ad020a4644d853182612252f7f45 Mon Sep 17 00:00:00 2001 From: nishi Date: Sun, 5 May 2024 14:11:52 +0000 Subject: [PATCH] fix git-svn-id: file:///raid/svn-main/nishi-serenade/trunk@108 0f02c867-ac3d-714e-8a88-971ba1f6efcf --- Serenade/interpreter.c | 12 ++++++++---- Serenade/run.c | 3 +++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Serenade/interpreter.c b/Serenade/interpreter.c index 38a8ebe..8908887 100644 --- a/Serenade/interpreter.c +++ b/Serenade/interpreter.c @@ -185,18 +185,22 @@ struct sn_interpreter* sn_create_interpreter(void) { void sn_interpreter_free(struct sn_interpreter* sn) { int i; +do_again: for(i = 0; sn->variables[i] != NULL; i++) { if(sn->variables[i] != NULL) { free(sn->variables[i]->key); - if(sn->variables[i]->value != NULL) sn_generic_free(sn, sn->variables[i]->value); - sn->variables[i]->value = NULL; - free(sn->variables[i]); + if(sn->variables[i]->value != NULL) { + sn_generic_free(sn, sn->variables[i]->value); + goto do_again; + } } } for(i = 0; sn->generics[i] != NULL; i++) { int j; + do_again2: for(j = 0; sn->generics[i][j] != NULL; j++) { - sn_generic_free(sn, sn->generics[i][j]); + if(sn->generics[i][j] != (void*)1) sn_generic_free(sn, sn->generics[i][j]); + goto do_again2; } free(sn->generics[i]); } diff --git a/Serenade/run.c b/Serenade/run.c index 024718f..fc27efb 100644 --- a/Serenade/run.c +++ b/Serenade/run.c @@ -103,6 +103,9 @@ struct sn_generic* _sn_run(struct sn_interpreter* sn, struct sn_generic* gen) { kv->argvalue = gen->tree->args + 1; free(name); return r; + } else if(strcmp(op->name, "loop") == 0) { + r->type = SN_TYPE_VOID; + return r; } bool called = false; int j; -- 2.43.0