refactoring
[rrq/rrqmisc.git] / vector / View.c
index 5da2bcc0719a466c3d754e099ace0e66826ba9cc..5b3179a9738d0ec8bea182c1a84695790b20dfba 100644 (file)
@@ -27,7 +27,7 @@ typedef struct {
      * This is the collection of bindings for the tracked names being
      * gained at the latest evaluation.
      */
-    HashVector gained;
+    Vector gained;
     /**
      * This is the collection of bindings for the tracked names being
      * last at the latest evaluation.
@@ -39,13 +39,23 @@ static Tuple *View_type_Tuple(HashVector *hv) {
     Tuple *t = Tuple_calloc( hv->fill );
     VectorIndex index = 0;
     for ( ; index < hv->table.size; index++ ) {
-       t->elements[ index ] = &stringitem;
+       t->elements[ index ] = HashVector_next( hv, &index );
     }
     return t;
 }
 
+static void View_reclaim(Query *this) {
+    View *v = (View*) this;
+    TupleSchema *ts = (TupleSchema*) gained->type;
+    Vector_resize( &v->gained, 0, Vector_clear_any, 0 );
+    Vector_resize( &v->lost, 0, Vector_clear_any, 0 );
+    free( ts->columns );
+    free( ts );
+    free( this );
+}
+
 static QueryCallbacks View_def = {
-    .reclaim = 0,
+    .reclaim = View_reclaim,
     .next = 0,
     .variables = 0
 };
@@ -82,5 +92,6 @@ Query *View_create(Query *q) {
            .fill = 0, .holes = 0, .type = (ItemKeyFun*) ts
        }
     };
+    Vector_resize( &hv, 0, Vector_clear_any, 0 );
     return (Query*) vq;
 }