Corrects all known memory leaks
This commit is contained in:
parent
c7d3d7f457
commit
d4d1f27a63
|
@ -64,8 +64,9 @@ struct Environment envForLambda(const Object *params, const Object *arg_forms,
|
||||||
for(int i = 0; i < paramCount; i++) {
|
for(int i = 0; i < paramCount; i++) {
|
||||||
const char *newObjName = itemAt(params, i)->string;
|
const char *newObjName = itemAt(params, i)->string;
|
||||||
// Eval the `march` list
|
// Eval the `march` list
|
||||||
const Object newEnvObj = eval(march, outer);
|
Object newEnvObj = eval(march, outer);
|
||||||
addToEnv(&env, newObjName, newEnvObj); // Could use eval_forms?
|
addToEnv(&env, newObjName, newEnvObj); // Could use eval_forms?
|
||||||
|
cleanObject(&newEnvObj);
|
||||||
march = march->forward;
|
march = march->forward;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,9 +45,12 @@ Object evalDefArgs(const Object *symbol, const Object *value, struct Environment
|
||||||
|
|
||||||
Object evalIfArgs(const Object *argForms, struct Environment *env)
|
Object evalIfArgs(const Object *argForms, struct Environment *env)
|
||||||
{
|
{
|
||||||
return eval(argForms, env).number ?
|
Object condition = eval(argForms, env);
|
||||||
|
Object result = condition.number ?
|
||||||
eval(argForms->forward, env) :
|
eval(argForms->forward, env) :
|
||||||
eval(argForms->forward->forward, env);
|
eval(argForms->forward->forward, env);
|
||||||
|
cleanObject(&condition);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object evalLambdaArgs(const Object *argForms)
|
Object evalLambdaArgs(const Object *argForms)
|
||||||
|
@ -242,7 +245,7 @@ Object evalList(const Object *obj, struct Environment *env)
|
||||||
if(listLength(obj->list) == 0) {
|
if(listLength(obj->list) == 0) {
|
||||||
return cloneObject(*obj);
|
return cloneObject(*obj);
|
||||||
}
|
}
|
||||||
return startList(cloneObject(eval(obj->list, env)));
|
return startList(eval(obj->list, env));
|
||||||
}
|
}
|
||||||
|
|
||||||
Object *first_form = obj->list;
|
Object *first_form = obj->list;
|
||||||
|
@ -735,7 +738,8 @@ Object parseEval(const char *input, struct Environment *env)
|
||||||
cleanObject(&obj);
|
cleanObject(&obj);
|
||||||
Object parsed = parse(tok).obj;
|
Object parsed = parse(tok).obj;
|
||||||
if(parsed.type == TYPE_ERROR) {
|
if(parsed.type == TYPE_ERROR) {
|
||||||
return parsed;
|
obj = parsed;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if(tok[i].text[0] == ')') {
|
if(tok[i].text[0] == ')') {
|
||||||
tok = &tok[i + 1];
|
tok = &tok[i + 1];
|
||||||
|
|
Loading…
Reference in New Issue