altos/lisp: re-use small frames
[fw/altos] / src / lisp / ao_lisp_eval.c
index 3af567964deab8a4f87d13a26d13425e3508e901..6f56a1205aee9a561e070dc68327175880af17d7 100644 (file)
@@ -122,7 +122,8 @@ ao_lisp_stack_push(void)
 static void
 ao_lisp_stack_pop(void)
 {
-       ao_poly prev;
+       ao_poly                 prev;
+       struct ao_lisp_frame    *prev_frame;
 
        if (!ao_lisp_stack)
                return;
@@ -131,10 +132,13 @@ ao_lisp_stack_pop(void)
        ao_lisp_stack_free_list = ao_lisp_stack;
 
        ao_lisp_stack = ao_lisp_poly_stack(prev);
+       prev_frame = ao_lisp_frame_current;
        if (ao_lisp_stack)
                ao_lisp_frame_current = ao_lisp_poly_frame(ao_lisp_stack->frame);
        else
                ao_lisp_frame_current = NULL;
+       if (ao_lisp_frame_current != prev_frame)
+               ao_lisp_frame_free(prev_frame);
        DBG_OUT();
        DBGI("stack pop\n");
        DBG_FRAMES();