mumble

A Lisp written in C, following the *Build Your Own Lisp* book
Log | Files | Refs | README

commit 789a48ccbcf8fb4c875c35c100d86eae624ade45
parent 140788b8ed5f0172a0fad8c01a31085ce4942e2a
Author: NunoSempere <nuno.sempere@protonmail.com>
Date:   Sun,  7 May 2023 22:17:38 -0400

solve bug #1 when deleting lispval

Diffstat:
Mmumble | 0
Msrc/mumble.c | 14++++++++------
2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/mumble b/mumble Binary files differ. diff --git a/src/mumble.c b/src/mumble.c @@ -251,16 +251,16 @@ void delete_lispval(lispval* v) case LISPVAL_USER_FUNC: if(VERBOSE) printfln("This shouldn't fire until the end, unless we are deleting the operands of a builtin function. E.g,. in def {id} (@ {x} {x}), there is a lambda function in the arguments, which should get collected."); // for now, do nothing - /* if (VERBOSE) printfln("Freeing user-defined func"); if (v->env != NULL) { - // destroy_lispenv(v->env); - // free(v->env); - //v->env = NULL; + destroy_lispenv(v->env); + // ^ free(v->env) is not necessary; taken care of by destroy_lispenv + v->env = NULL; } if (v->variables != NULL) { // delete_lispval(v->variables); + // free(v->variables) // v->variables = NULL; } if (v->manipulation != NULL) { @@ -269,12 +269,14 @@ void delete_lispval(lispval* v) // v->manipulation = NULL; } if (v != NULL) - // free(v); + free(v); if (VERBOSE) printfln("Freed user-defined func"); // Don't do anything with v->func for now // Though we could delete the pointer to the function later - // free(v->func); + // + // free(v->func); + /* */ break; case LISPVAL_SEXPR: