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

domain* domain_new ( resourcetype restype  ) 

Creates a new full domain. (domain with all possible values for a specified resource type).

The allocated domain contains no tuples.

Parameters:
restype Resource type for this domain.
Returns:
Pointer to the created domain struct or NULL on error.

Definition at line 64 of file data.c.

References domain_t::next, domain_t::prev, resourcetype_t::resnum, domain_t::restype, domain_t::tuplenum, domain_t::tuples, domain_t::val, and domain_t::valnum.

Referenced by tuple_new().

{
      domain *result;
      int n;

      assert(restype!=NULL);

      result=malloc(sizeof(*result));
      if(result==NULL) return(NULL);

      result->tuplenum=0;
      result->tuples=NULL;

      result->restype=restype;

      result->valnum=restype->resnum;

      result->val=malloc(sizeof(*result->val)*result->valnum);
      if(result->val==NULL) {
            free(result);
            return(NULL);
      }

      for(n=0;n<result->valnum;n++) {
            result->val[n]=n;
      }

      result->prev=NULL;
      result->next=dat_domains;
      if(dat_domains!=NULL) {
            dat_domains->prev=result;
      }

      dat_domains=result;

      return(result);
}


Generated by  Doxygen 1.6.0   Back to index