fix: fix some memory errors by doing the proper thing
on expr evaluation
This commit is contained in:
parent
59b92a6479
commit
6316fe2426
17
src/mumble.c
17
src/mumble.c
|
@ -856,12 +856,21 @@ lispval* evaluate_lispval(lispval* l, lispenv* env)
|
|||
if (VERBOSE)
|
||||
print_lispval_tree(l, 4);
|
||||
|
||||
// Ok, do this properly now.
|
||||
if (VERBOSE)
|
||||
printfln("Constructing function and operands");
|
||||
lispval* f = clone_lispval(l->cell[0]);
|
||||
lispval* operands = lispval_sexpr();
|
||||
for(int i=1; i<l->count; i++){
|
||||
lispval_append_child(operands, l->cell[i]);
|
||||
|
||||
}
|
||||
/*
|
||||
lispval* temp = clone_lispval(l);
|
||||
lispval* f = pop_lispval(temp, 0);
|
||||
// pop is destructive.
|
||||
lispval* operands = temp;
|
||||
if (VERBOSE)
|
||||
printfln("Allocated memory");
|
||||
*/
|
||||
// lispval* operation = clone_lispval(l->cell[0]);
|
||||
// lispval* operands = lispval_sexpr();
|
||||
// for (int i = 1; i < l->count; i++) {
|
||||
|
@ -871,9 +880,9 @@ lispval* evaluate_lispval(lispval* l, lispenv* env)
|
|||
printfln("Applying function to operands");
|
||||
// lispval* answer = lispval_num(42);
|
||||
lispval* answer = f->func(operands, env);
|
||||
|
||||
if (VERBOSE)
|
||||
printfln("Applied function to operands");
|
||||
|
||||
if (VERBOSE)
|
||||
printfln("Cleaning up");
|
||||
// builtin_functions(operation->sym, l, env);
|
||||
|
@ -881,7 +890,7 @@ lispval* evaluate_lispval(lispval* l, lispenv* env)
|
|||
delete_lispval(operands);
|
||||
// delete_lispval(temp);
|
||||
if (VERBOSE)
|
||||
printfln("Returning");
|
||||
printfln("Cleaned up. Returning");
|
||||
return answer;
|
||||
}
|
||||
return l;
|
||||
|
|
Loading…
Reference in New Issue
Block a user