add reference counter for future smarter allocations
[lambda.git] / lambda.y
index 07c6b80..388693d 100644 (file)
--- a/lambda.y
+++ b/lambda.y
@@ -31,7 +31,9 @@ int yywrap()
 
 struct lambda *make_lambda()
 {
-       return malloc(sizeof (struct lambda));
+       struct lambda *t = malloc(sizeof (struct lambda));
+       t->refcount = 1;
+       return t;
 }
 
 struct lambda *make_ident(char *i)
@@ -119,7 +121,7 @@ lambda
                {
                        int maxdepth = 1000;
                        printf("     ");
-                       lambda_reduce($1, $1, &maxdepth);
+                       lambda_reduce(&$1, &$1, &maxdepth);
                        lambda_print($1, NULL);
                        lambda_free($1);
                }