From: Ralph Ronnquist Date: Wed, 13 Jul 2022 06:07:47 +0000 (+1000) Subject: add Tuple_calloc X-Git-Url: https://git.rrq.au/?a=commitdiff_plain;h=4e5a12ca4bfd6541fac14c1b0fa0d6e12168ce88;p=rrq%2Frrqmisc.git add Tuple_calloc --- diff --git a/vector/Tuple.c b/vector/Tuple.c index 06eba85..e5341bd 100644 --- a/vector/Tuple.c +++ b/vector/Tuple.c @@ -3,6 +3,13 @@ #include #include +Tuple *Tuple_calloc(int arity) { + Tuple *t = (Tuple *) malloc( sizeof( Tuple ) + arity * sizeof( void* ) ); + t->types = 0; + memset( t->elements, 0, arity * sizeof( void* ) ); + return t; +} + // Allocate Tuple *Tuple_create(int arity,...) { va_list ap; @@ -23,6 +30,7 @@ Tuple *Tuple_clone(int arity,Tuple *t) { return ct; } +#if 0 unsigned long Tuple_mask(int arity,Tuple *t) { unsigned long mask = 0; while ( arity-- > 0 ) { @@ -33,3 +41,4 @@ unsigned long Tuple_mask(int arity,Tuple *t) { } return mask; } +#endif diff --git a/vector/Tuple.h b/vector/Tuple.h index b14d196..fb6bbd6 100644 --- a/vector/Tuple.h +++ b/vector/Tuple.h @@ -13,21 +13,25 @@ typedef struct { void *elements[]; } Tuple; -extern ItemKeyFun *Tuple_elementType(Tuple *t,unsigned long index); - /** - * Create a tuples with given values. + * \brief Create an untyped tuple with given values. * - * \related TupleSchema + * \related Tuple */ extern Tuple *Tuple_create(int arity,...); /** - * \brief Create a tuples as a clone of a given tuple + * \brief Create an untyped tuple with 0 values. * - * \related TupleSchema + * \related Tuple */ -extern Tuple *Tuple_clone(int arity,Tuple *t); +extern Tuple *Tuple_calloc(int arity); +/** + * \brief Create a tuple as a clone of a given tuple. + * + * \related Tuple + */ +extern Tuple *Tuple_clone(int arity,Tuple *t); #endif