Allocate Fur stacks on the C heap
[fur] / templates / function_definition.c
index c483bda..d20eba6 100644 (file)
@@ -3,9 +3,7 @@ Object user${{name}}$implementation(EnvironmentPool* environmentPool, Environmen
 {
   environment = Environment_construct(environmentPool, environment);
 
-  Stack stackMemory;
-  Stack* stack = &stackMemory;
-  Stack_initialize(stack);
+  Stack* stack = Stack_construct();
 
   jmp_buf jump;
   if(setjmp(jump) != 0)
@@ -19,6 +17,8 @@ Object user${{name}}$implementation(EnvironmentPool* environmentPool, Environmen
     }
     Environment_setLive(environment, false);
 
+    Stack_destruct(stack);
+
     longjmp(parentJump, 1);
   }
 
@@ -34,5 +34,7 @@ Object user${{name}}$implementation(EnvironmentPool* environmentPool, Environmen
 
   // TODO Set the environment back to the parent environment
   Environment_setLive(environment, false);
+
+  Stack_destruct(stack);
   return result;
 }