diff --git a/parse.c b/parse.c index 6180434..084d376 100644 --- a/parse.c +++ b/parse.c @@ -160,7 +160,10 @@ struct Value *ParseFunctionDefinition(struct ParseState *Parser, struct ValueTyp if (TableGet(&GlobalTable, Identifier, &OldFuncValue, NULL, NULL)) { if (OldFuncValue->Val->FuncDef.Body.Pos == NULL) - TableDelete(&GlobalTable, Identifier); /* override an old function prototype */ + { + /* override an old function prototype */ + VariableFree(TableDelete(&GlobalTable, Identifier)); + } else ProgramFail(Parser, "'%s' is already defined", Identifier); } diff --git a/table.c b/table.c index 8ed2658..1dd0032 100644 --- a/table.c +++ b/table.c @@ -106,8 +106,11 @@ struct Value *TableDelete(struct Table *Tbl, const char *Key) { if ((*EntryPtr)->p.v.Key == Key) { - struct Value *Val = (*EntryPtr)->p.v.Val; - *EntryPtr = (*EntryPtr)->Next; + struct TableEntry *DeleteEntry = *EntryPtr; + struct Value *Val = DeleteEntry->p.v.Val; + *EntryPtr = DeleteEntry->Next; + HeapFreeMem(DeleteEntry); + return Val; } } diff --git a/tests/30_hanoi.c b/tests/30_hanoi.c index 42ce561..c5846c6 100644 --- a/tests/30_hanoi.c +++ b/tests/30_hanoi.c @@ -26,8 +26,11 @@ Recreations & Essays, W.W. Rouse Ball, MacMillan, NewYork, 11th Ed. 1967, * */ -#include -#include +#include +#include + +#define TRUE 1 +#define FALSE 0 #define N 4 /* This is the number of "disks" on tower A initially. */ /* Taken to be 64 in the legend. The number of moves @@ -67,16 +70,33 @@ PrintAll() int Move(int *source, int *dest) { - int i=0,j=0; + int i,j; + int done = FALSE; - while((*(source + i)==0)&&(i