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

int compact_domains (  ) 

Finds and merges duplicate domains.

This function must be called after all tuples were added.

Returns:
0 on success and -1 on error.

Definition at line 230 of file data.c.

References dat_tuplenum, dat_typenum, debug(), tupleinfo_t::dom, domain_addtuple(), domain_compare(), domain_free(), error(), tupleinfo_t::name, domain_t::next, domain_t::restype, domain_t::tuplenum, domain_t::tuples, resourcetype_t::type, and domain_t::valnum.

Referenced by data_init().

{
      int tupleid, typeid;

      domain **tupdom;
      domain *cur;

      int num;
      int n,retval;
      char *name;

      for(tupleid=0;tupleid<dat_tuplenum;tupleid++) {
            for(typeid=0;typeid<dat_typenum;typeid++) {
                  tupdom=&dat_tuplemap[tupleid].dom[typeid];
                  
                  cur=dat_domains;
                  while(cur!=NULL) {
                        if(cur!=*tupdom) {
                              if(domain_compare(cur, *tupdom)) {
                                    break;
                              }
                        }
                        cur=cur->next;
                  }

                  if(cur!=NULL) {
                        domain_free(*tupdom);
                        *tupdom=cur;

                        domain_addtuple(cur, &dat_tuplemap[tupleid]);
                  }
            }
      }

      /* Check compacted domains */

      cur=dat_domains;
      num=0;
      retval=0;
      while(cur!=NULL) {
            assert(cur->tuplenum>0);
            
            debug("compact_domains: %d tuples in %d", cur->tuplenum, num);

            if(cur->valnum<1) {
                  error(_("Domain '%d' for resource type '%d' is empty"),
                                    num, cur->restype->type);
                  for(n=0;n<cur->tuplenum;n++) {
                        tupleid=cur->tuples[n];
                        name=dat_tuplemap[tupleid].name;
                              
                        error(_("Domain '%d' is used by event '%s'"), 
                              num, name);
                  }
                  retval=-1;
            }
            num++;
            cur=cur->next;
      }

      return(retval);
}


Generated by  Doxygen 1.6.0   Back to index