diff --git a/src/Makefile b/src/Makefile index 18dd951..06f728e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,7 +1,7 @@ exe = pl base_files = main.c pebblisp.c tokens.c object.c env.c hash.c -func_files = plfunc/web.c plfunc/plfunc.c plfunc/threads.c plfunc/plstring.c plfunc/pc.c +func_files = plfunc/web.c plfunc/general.c plfunc/threads.c plfunc/plstring.c plfunc/pc.c files:= $(base_files) $(func_files) libs = -lreadline -lmicrohttpd -lpthread diff --git a/src/env.c b/src/env.c index 82c9f39..a6b692c 100644 --- a/src/env.c +++ b/src/env.c @@ -7,7 +7,7 @@ #include "pebblisp.h" #include "plfunc/web.h" #include "plfunc/threads.h" -#include "plfunc/plfunc.h" +#include "plfunc/general.h" #include "plfunc/pc.h" #include "plfunc/plstring.h" @@ -480,10 +480,12 @@ int runTest(const char* test, const char* expected, int detailed) size_t length; char* result = stringObj(&o, &length); cleanObject(&o); - int expectedLen = 0; + + int expectedLen = 0; // Don't count anything after a semicolon while (expected[expectedLen] && expected[expectedLen] != ';') { expectedLen++; } + int ret; if (strncmp(result, expected, expectedLen) != 0) { ret = 0; @@ -491,10 +493,10 @@ int runTest(const char* test, const char* expected, int detailed) printf("%s\n", test); printf("Expected '%s' but received '%s'\n", expected, result); } else { + ret = 1; if (detailed) { printf("✓"); } - ret = 1; } free(result); deleteEnv(&env); diff --git a/src/object.c b/src/object.c index 6fa3ad4..48fe0d1 100644 --- a/src/object.c +++ b/src/object.c @@ -421,7 +421,14 @@ void cleanObject(Object* target) if (!lambdaRefs(target)) { cleanObject(&target->lambda->params); cleanObject(&target->lambda->body); - free(lambdaDocs(target)); + char** docTexts = lambdaDocs(target); + if (docTexts) { + while (*docTexts) { + free(*docTexts); + docTexts++; + } + free(lambdaDocs(target)); + } free(target->lambda); } return; diff --git a/src/plfunc/plfunc.c b/src/plfunc/general.c similarity index 99% rename from src/plfunc/plfunc.c rename to src/plfunc/general.c index f5fd9dc..6538951 100644 --- a/src/plfunc/plfunc.c +++ b/src/plfunc/general.c @@ -2,7 +2,7 @@ #include #include -#include "plfunc.h" +#include "general.h" Object reduce(Object* params, unused int length, struct Environment* env) { diff --git a/src/plfunc/plfunc.h b/src/plfunc/general.h similarity index 98% rename from src/plfunc/plfunc.h rename to src/plfunc/general.h index 691a895..bf0f9b0 100644 --- a/src/plfunc/plfunc.h +++ b/src/plfunc/general.h @@ -1,5 +1,5 @@ -#ifndef PEBBLISP_PLFUNC_H -#define PEBBLISP_PLFUNC_H +#ifndef PEBBLISP_GENERAL_H +#define PEBBLISP_GENERAL_H #include "../pebblisp.h" @@ -181,4 +181,4 @@ tfn(getTime, "time", "Get a struct of the current time with fields (minute hour sec)." ); -#endif // PEBBLISP_PLFUNC_H +#endif // PEBBLISP_GENERAL_H