]> Nishi Git Mirror - serenade.git/commitdiff
fix
authornishi <nishi@0f02c867-ac3d-714e-8a88-971ba1f6efcf>
Sun, 5 May 2024 14:11:52 +0000 (14:11 +0000)
committernishi <nishi@0f02c867-ac3d-714e-8a88-971ba1f6efcf>
Sun, 5 May 2024 14:11:52 +0000 (14:11 +0000)
git-svn-id: file:///raid/svn-main/nishi-serenade/trunk@108 0f02c867-ac3d-714e-8a88-971ba1f6efcf

Serenade/interpreter.c
Serenade/run.c

index 38a8ebedd746542330d431b09de8b1e68c3b5716..8908887fac6c592d1df1819c59b23f4573fd4498 100644 (file)
@@ -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]);
        }
index 024718fe5fab24808755efa23e78ff2f01c1525d..fc27efb045caf4fb1ac8fd711ab2abe0381824d9 100644 (file)
@@ -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;