Correct known memory leaks.

This commit is contained in:
Sage Vaillancourt 2022-03-17 13:23:19 -04:00 committed by Sage Vaillancourt
parent 011ed937fe
commit 13a7ad97b5
1 changed files with 9 additions and 10 deletions

View File

@ -74,9 +74,8 @@ struct Environment envForLambda(const Object* params, const Object* arg_forms,
march = march->forward;
}
while(outer) {
if(outer) {
outer->refs += 1;
outer = outer->outer;
}
return env;
}
@ -196,13 +195,6 @@ void deleteEnv(struct Environment* e)
deleteEnv(e->outer);
}
for (int i = 0; i < e->structCount; i++) {
free(e->structDefs[i].name);
for (int j = 0; j < e->structDefs[i].fieldCount; j++) {
free(e->structDefs[j].names);
}
}
if (e->strings) {
int i = 0;
while (e->strings[i]) {
@ -212,10 +204,17 @@ void deleteEnv(struct Environment* e)
}
free(e->strings);
e->strings = NULL;
free(e->objects);
e->objects = NULL;
}
for (int i = 0; i < e->structCount; i++) {
free(e->structDefs[i].name);
for (int j = 0; j < e->structDefs[i].fieldCount; j++) {
free(e->structDefs[i].names[j]);
}
free(e->structDefs[i].names);
}
free(e->structDefs);
}