commit after resolving conflict
[satune.git] / src / AST / table.c
index 48bd532d52c4aade239cb49c9cc35f5cd15e00e8..1f95f43c1d4b61d23a32f67ba4f9f6b220f3337b 100644 (file)
@@ -2,6 +2,7 @@
 #include "common.h"
 #include "structs.h"
 #include "tableentry.h"
+#include "set.h"
 
 
 Table * allocTable(Set **domains, uint numDomain, Set * range){
@@ -11,6 +12,7 @@ Table * allocTable(Set **domains, uint numDomain, Set * range){
         pushVectorSet(table->domains, domains[i]);
     }
     table->range =range;
+               return table;
 }
 
 void addNewTableEntry(Table* table, uint64_t* inputs, uint inputSize, uint64_t result){
@@ -18,3 +20,17 @@ void addNewTableEntry(Table* table, uint64_t* inputs, uint inputSize, uint64_t r
     pushVectorTableEntry(table->entries, allocTableEntry(inputs, inputSize, result));
 }
 
+void deleteTable(Table* table){
+    uint size = getSizeVectorSet(table->domains);
+    for(uint i=0; i<size; i++){
+       deleteSet(getVectorSet(table->domains,i));
+    }
+    ourfree(table->domains);
+    ourfree(table->range);
+    size = getSizeVectorTableEntry(table->entries);
+    for(uint i=0; i<size; i++){
+       deleteTableEntry(getVectorTableEntry(table->entries, i));
+    }
+    ourfree(table);
+}
+