X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;f=vector%2FBindingTable.c;h=e3ef2147e91bf3ea286546e74a5e104bdf9e0af0;hb=58de9483c458a25a691d648ce13b81227c327d03;hp=7f9d3440ef79e8b679e6873121bfcad8abcc5408;hpb=6fcd4ffc18696dbf4c11be32837a2035ea5ee92f;p=rrq%2Frrqmisc.git diff --git a/vector/BindingTable.c b/vector/BindingTable.c index 7f9d344..e3ef214 100644 --- a/vector/BindingTable.c +++ b/vector/BindingTable.c @@ -117,11 +117,11 @@ void *BindingTable_get(BindingTable *bt,char *name) { return 0; } -void BindingTable_deref(BindingTable *bt,int arity,tuple *t) { +void BindingTable_deref(BindingTable *bt,int arity,Tuple *t) { int i; for ( i = 0; i < arity; i++ ) { - if ( (*t)[i] ) { - (*t)[i] = BindingTable_get( bt, (*t)[i] ); + if ( t->elements[i] ) { + t->elements[i] = BindingTable_get( bt, t->elements[i] ); } } } @@ -141,16 +141,15 @@ int BindingTable_unify( #define COPYA(T,P,N) (T*) memcpy( malloc( N * sizeof(T) ), P, N * sizeof( T ) ) -tuple *BindingTable_tuple_get(BindingTable *bt,int arity,tuple *t) { - tuple *vt = (tuple*) memcpy( - malloc( arity * sizeof( void* ) ), t, arity * sizeof( void* ) ); +Tuple *BindingTable_tuple_get(BindingTable *bt,int arity,Tuple *t) { + Tuple *vt = Tuple_clone( arity, t ); BindingTable_deref( bt, arity, vt ); return vt; } -void BindingTable_tuple_set(BindingTable *bt,int arity,tuple *nm,tuple *vs) { +void BindingTable_tuple_set(BindingTable *bt,int arity,Tuple *nm,Tuple *vs) { int i; for ( i = 0; i < arity; i++ ) { - BindingTable_set( bt, (*nm)[i], (*vs)[i] ); + BindingTable_set( bt, nm->elements[i], vs->elements[i] ); } }