new type tab_t and rebuild of stack
[calc.git] / program.c
index 3c94986fbbc7c1f7f2b2a9dac321c3a5db476ec2..97f99293114bd95b76ac4601d62c4b5645fd1a4f 100644 (file)
--- a/program.c
+++ b/program.c
@@ -6,6 +6,7 @@
 #include "parser.h"
 #include "stack.h"
 #include "storage.h"
+#include "tabular.h"
 
 #include "program.h"
 
@@ -54,7 +55,7 @@ void prog (int id, element_t *root)
                 free ((programs + n)->storage);
             }
             if ((programs + n)->stack) {
-                free ((programs + n)->stack);
+                free_tab ((programs + n)->stack);
             }
             if ((programs + n)->root) {
                 delelement ((programs + n)->root);
@@ -72,7 +73,6 @@ void prog (int id, element_t *root)
     (programs + n)->storage = NULL;
     (programs + n)->storage_size = 0;
     (programs + n)->stack = NULL;
-    (programs + n)->stack_size = 0;
     (programs + n)->root = dupelement (root);
 }
 
@@ -115,7 +115,6 @@ double call (int id, int nbargs, element_t **args)
     tmp.storage = storage;
     tmp.storage_size = storage_size;
     tmp.stack = stack;
-    tmp.stack_size = stack_size;
 
     /* change context */
     answer = 0;
@@ -124,7 +123,6 @@ double call (int id, int nbargs, element_t **args)
     argument = NULL;
     argument_size = 0;
     stack = (programs + n)->stack;
-    stack_size = (programs + n)->stack_size;
     if (nbargs > 0) {
         argument = (double *) callocordie (nbargs, sizeof (double));
         for (i = 0, l = 0; i < nbargs; l++) {
@@ -146,7 +144,6 @@ double call (int id, int nbargs, element_t **args)
         free (argument);
     }
     (programs + n)->stack = stack;
-    (programs + n)->stack_size = stack_size;
 
     /* restore context */
     answer = tmp.answer;
@@ -155,7 +152,6 @@ double call (int id, int nbargs, element_t **args)
     argument = tmp.argument;
     argument_size = tmp.argument_size;
     stack = tmp.stack;
-    stack_size = tmp.stack_size;
 
     return ret;
 }
@@ -246,7 +242,7 @@ void del (int id)
         free ((programs + n)->storage);
     }
     if ((programs + n)->stack) {
-        free ((programs + n)->stack);
+        free_tab ((programs + n)->stack);
     }
     if ((programs + n)->root) {
         delelement ((programs + n)->root);