Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
cullvox committed May 22, 2023
2 parents 38e008c + d54d191 commit b2b21f7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
build
# We use this folder to build into, keep the directories clean
build

# CMAKE
CMakeCache.txt
6 changes: 4 additions & 2 deletions Examples/Sandbox/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 10 additions & 2 deletions Source/noodle.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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:
Expand All @@ -1272,7 +1275,7 @@ void noodleFree(Noodle_t* pNoodle)

pToFree = pNode;
pNode = pNode->pNext;

NOODLE_FREE(pToFree);
pToFree = NULL;
}
Expand All @@ -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);
Expand All @@ -1295,6 +1302,7 @@ void noodleFree(Noodle_t* pNoodle)
{
NoodleValue_t* pValue = (NoodleValue_t*)pNoodle;
NOODLE_FREE(pValue->s);
NOODLE_FREE(pValue);
break;
}

Expand Down
3 changes: 3 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mkdir build
cmake -S . -B build
make build

0 comments on commit b2b21f7

Please sign in to comment.