]> Nishi Git Mirror - serenade.git/commitdiff
should work
authornishi <nishi@0f02c867-ac3d-714e-8a88-971ba1f6efcf>
Sat, 27 Apr 2024 08:29:50 +0000 (08:29 +0000)
committernishi <nishi@0f02c867-ac3d-714e-8a88-971ba1f6efcf>
Sat, 27 Apr 2024 08:29:50 +0000 (08:29 +0000)
git-svn-id: file:///raid/svn-main/nishi-serenade/trunk@77 0f02c867-ac3d-714e-8a88-971ba1f6efcf

Serenade/interpreter.c

index 269208ecacce7a4673a919c0aeaedb661cc0bcdd..eca822588bcfc5eb7622792eab772fb0ce65c1fc 100644 (file)
@@ -180,18 +180,33 @@ struct sn_interpreter* sn_create_interpreter(void) {
 
 void sn_interpreter_free(struct sn_interpreter* sn) {
        int i;
+       for(i = 0; sn->variables[i] != NULL; i++);
+       void** ptrs = malloc(sizeof(void*) * (i + 1));
        for(i = 0; sn->variables[i] != NULL; i++) {
+               ptrs[i] = sn->variables[i]->value;
                free(sn->variables[i]->key);
                if(sn->variables[i]->value != NULL) sn_generic_free(sn->variables[i]->value);
                free(sn->variables[i]);
        }
+       ptrs[i] = NULL;
        free(sn->variables);
        for(i = 0; sn->generics[i] != NULL; i++) {
                int j;
-               for(j = 0; sn->generics[i][j] != NULL; j++) sn_generic_free(sn->generics[i][j]);
+               for(j = 0; sn->generics[i][j] != NULL; j++){
+                       int k;
+                       bool found = false;
+                       for(k = 0; ptrs[k] != NULL; k++){
+                               if(ptrs[k] == sn->generics[i][j]){
+                                       found = true;
+                                       break;
+                               }
+                       }
+                       if(!found) sn_generic_free(sn->generics[i][j]);
+               }
                free(sn->generics[i]);
        }
        free(sn->generics);
+       free(ptrs);
        free(sn);
 }