Got character walking around, fixed leak

This commit is contained in:
2023-03-04 08:19:18 +11:00
parent f152afc9d7
commit 3df788e69a
7 changed files with 164 additions and 6 deletions

View File

@@ -146,8 +146,10 @@ static inline void execLoadRootNode() {
//immediately call onLoad() after running the script - for loading other nodes
Box_callEngineNode(engine.rootNode, &inner, "onLoad", NULL);
//cache the scope for later freeing
engine.rootNode->scope = inner.scope;
//manual cleanup
Toy_popScope(inner.scope);
Toy_freeLiteralArray(&inner.stack);
Toy_freeLiteralArray(&inner.literalCache);
@@ -207,7 +209,7 @@ static inline void execEvents() {
//call the function
Toy_pushLiteralArray(&args, eventLiteral);
Box_callRecursiveEngineNode(engine.rootNode, &engine.interpreter, "onKeyDown", &args);
Toy_popLiteralArray(&args);
Toy_freeLiteral(Toy_popLiteralArray(&args));
//push to the event list
Toy_freeLiteral(eventLiteral);
@@ -234,7 +236,7 @@ static inline void execEvents() {
//call the function
Toy_pushLiteralArray(&args, eventLiteral);
Box_callRecursiveEngineNode(engine.rootNode, &engine.interpreter, "onKeyUp", &args);
Toy_popLiteralArray(&args);
Toy_freeLiteral(Toy_popLiteralArray(&args));
//push to the event list
Toy_freeLiteral(eventLiteral);