diff --git a/.gitignore b/.gitignore index c795b05..fc8666e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ -build \ No newline at end of file +# We use this folder to build into, keep the directories clean +build + +# CMAKE +CMakeCache.txt \ No newline at end of file diff --git a/Examples/Sandbox/main.c b/Examples/Sandbox/main.c index 70b0b10..9f26d81 100644 --- a/Examples/Sandbox/main.c +++ b/Examples/Sandbox/main.c @@ -49,8 +49,10 @@ int main(int argc, const char* argv[]) { char pErrorBuffer[256] = {0}; - NoodleGroup_t* pConfig = noodleParse(pContent, pErrorBuffer, sizeof(pErrorBuffer) / sizeof(pErrorBuffer[0])); - if (!pConfig) + printf("Basic Noodle Parser Example written in C!\n"); + + NoodleGroup_t* pConfig = noodleParse(pContent, pErrorBuffer, sizeof(pErrorBuffer) / sizeof(pErrorBuffer[0])); + if (!pConfig) { printf("%s\n", pErrorBuffer); return EXIT_FAILURE; diff --git a/Source/noodle.c b/Source/noodle.c index af77680..7fbde2d 100644 --- a/Source/noodle.c +++ b/Source/noodle.c @@ -914,7 +914,7 @@ NoodleLexer_t noodleLexer(const char* pContent) return (NoodleLexer_t){pContent, 0, 0, 0}; } -static NOODLE_BOOL noodleLexerIsIdentifier(char c) +NOODLE_BOOL noodleLexerIsIdentifier(char c) { switch (c) { @@ -1254,6 +1254,9 @@ void noodleLexerString(NoodleLexer_t* pLexer, NoodleToken_t* pTokenOut) void noodleFree(Noodle_t* pNoodle) { + // Free the name of the any noodle + NOODLE_FREE(pNoodle->pName); + switch (pNoodle->type) { case NOODLE_TYPE_GROUP: @@ -1272,7 +1275,7 @@ void noodleFree(Noodle_t* pNoodle) pToFree = pNode; pNode = pNode->pNext; - + NOODLE_FREE(pToFree); pToFree = NULL; } @@ -1285,6 +1288,10 @@ void noodleFree(Noodle_t* pNoodle) case NOODLE_TYPE_ARRAY: { NoodleArray_t* pArray = (NoodleArray_t*)pNoodle; + + if (pArray->type == NOODLE_TYPE_STRING) + for (int i = 0; i < pArray->count; i++) + NOODLE_FREE(pArray->ppStrings[i]); NOODLE_FREE(pArray->pIntegers); NOODLE_FREE(pArray); @@ -1295,6 +1302,7 @@ void noodleFree(Noodle_t* pNoodle) { NoodleValue_t* pValue = (NoodleValue_t*)pNoodle; NOODLE_FREE(pValue->s); + NOODLE_FREE(pValue); break; } diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..17fbe99 --- /dev/null +++ b/build.sh @@ -0,0 +1,3 @@ +mkdir build +cmake -S . -B build +make build \ No newline at end of file