Logo Search packages:      
Sourcecode: tablix2 version File versions  Download package

tupleinfo* tuple_new ( char *  name  ) 

Add a new tuple.

After the first tuple was added, any calls to restype_new() and res_new() have unspecified effects.

Parameters:
name Name of the tuple (event).
Returns:
Pointer to the tupleinfo struct of the new tuple or NULL on error.

Definition at line 792 of file data.c.

References dat_tuplenum, dat_typenum, tupleinfo_t::dom, domain_addtuple(), domain_new(), tupleinfo_t::name, tupleinfo_t::resid, TUPLE_ALLOC_CHUNK, and tupleinfo_t::tupleid.

Referenced by parser_events().

{
      tupleinfo *dest;
      int n;

      assert(name!=NULL);
      assert(dat_tuplenum>=0);

      if(dat_tuplenum%TUPLE_ALLOC_CHUNK==0) {
            n=sizeof(*dat_tuplemap)*(dat_tuplenum+TUPLE_ALLOC_CHUNK);
            dat_tuplemap=realloc(dat_tuplemap, n);
            if(dat_tuplemap==NULL) return(NULL);
      }

      dest=&dat_tuplemap[dat_tuplenum];

      dest->resid=malloc(sizeof(*dest->resid)*dat_typenum);
      if(dest->resid==NULL) return(NULL);
      dest->dom=malloc(sizeof(*dest->dom)*dat_typenum);
      if(dest->dom==NULL) {
            free(dest->resid);
            return(NULL);
      }

      dest->tupleid=dat_tuplenum;

      for(n=0;n<dat_typenum;n++) {
            dest->resid[n]=INT_MIN;
            dest->dom[n]=domain_new(&dat_restype[n]);
            if(dest->dom[n]==NULL) {
                  free(dest->dom);
                  free(dest->resid);
                  return(NULL);
            }
            domain_addtuple(dest->dom[n], dest);
      }

      dest->name=strdup(name);

      dat_tuplenum++;

      return(dest);
}


Generated by  Doxygen 1.6.0   Back to index