From ca0877adb6cf697f5bd003b58fa3dd70a1351e70 Mon Sep 17 00:00:00 2001 From: uz Date: Tue, 2 Aug 2011 16:46:47 +0000 Subject: [PATCH] Fixed an error in the special purpose allocator in expr.c. git-svn-id: svn://svn.cc65.org/cc65/trunk@5109 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/ca65/expr.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ca65/expr.c b/src/ca65/expr.c index b8efe42b1..123e9ad65 100644 --- a/src/ca65/expr.c +++ b/src/ca65/expr.c @@ -94,10 +94,11 @@ static ExprNode* NewExprNode (unsigned Op) ExprNode* N; /* Do we have some nodes in the list already? */ - if (FreeExprNodes) { + if (FreeNodeCount) { /* Use first node from list */ N = FreeExprNodes; FreeExprNodes = N->Left; + --FreeNodeCount; } else { /* Allocate fresh memory */ N = xmalloc (sizeof (ExprNode)); @@ -124,6 +125,7 @@ static void FreeExprNode (ExprNode* E) /* Remember this node for later */ E->Left = FreeExprNodes; FreeExprNodes = E; + ++FreeNodeCount; } else { /* Free the memory */ xfree (E); @@ -1016,7 +1018,7 @@ static ExprNode* Factor (void) break; default: - if (LooseCharTerm && CurTok.Tok == TOK_STRCON && + if (LooseCharTerm && CurTok.Tok == TOK_STRCON && SB_GetLen (&CurTok.SVal) == 1) { /* A character constant */ N = GenLiteralExpr (TgtTranslateChar (SB_At (&CurTok.SVal, 0))); @@ -1471,8 +1473,8 @@ void FreeExpr (ExprNode* Root) { if (Root) { FreeExpr (Root->Left); - FreeExpr (Root->Right); - FreeExprNode (Root); + FreeExpr (Root->Right); + FreeExprNode (Root); } } -- 2.39.5