ASF_ASFConditionalEquationList ASF_unionASFConditionalEquationList(ASF_ASFConditionalEquationList cel1, ASF_OptLayout separator, ASF_ASFConditionalEquationList cel2) { if (!ASF_isASFConditionalEquationListEmpty(cel2)) { if (!ASF_isASFConditionalEquationListEmpty(cel1)) { int len1 = ASF_getASFConditionalEquationListLength(cel1); int len2 = ASF_getASFConditionalEquationListLength(cel2); ATermIndexedSet iSet = ATindexedSetCreate((len1+len2)*2, 75); ASF_ASFConditionalEquation ce; ASF_ASFConditionalEquationList newCel = ASF_makeASFConditionalEquationListEmpty(); int maxIndex = 0, index; while (ASF_hasASFConditionalEquationListHead(cel1)) { ce = ASF_getASFConditionalEquationListHead(cel1); index = ATindexedSetPut(iSet, ASF_ASFConditionalEquationToTerm(ce), NULL); if (index > maxIndex) { maxIndex = index; } if (ASF_hasASFConditionalEquationListTail(cel1)) { cel1 = ASF_getASFConditionalEquationListTail(cel1); } else { break; } } while (ASF_hasASFConditionalEquationListHead(cel2)) { ce = ASF_getASFConditionalEquationListHead(cel2); index = ATindexedSetPut(iSet, ASF_ASFConditionalEquationToTerm(ce), NULL); if (index > maxIndex) { maxIndex = index; } if (ASF_hasASFConditionalEquationListTail(cel2)) { cel2 = ASF_getASFConditionalEquationListTail(cel2); } else { break; } } for (index=0; index <= maxIndex; index++) { ce = ASF_ASFConditionalEquationFromTerm(ATindexedSetGetElem(iSet, index)); newCel = ASF_makeASFConditionalEquationListMany(ce, separator, newCel); } ATindexedSetDestroy(iSet); return newCel; } return cel2; } return cel1; }
tdb_t TDBcreate(int id, file_t file, channel_t channel) { tdb_t tdb = (tdb_t) calloc(1, sizeof(tdb_r)); if (tdb==NULL) { mkerror(ERR_NULL,"failed calloc(size = %d)",sizeof(tdb_r)); return NULL; } timer = createTimer(); // printmsg("TDBcreate: %d %lx %s", id, file, dir); tdb->type = TDB; tdb->role = SERVER; tdb->db = ATindexedSetCreate(tdb_size, 75); if (tdb->db==NULL) { mkerror(ERR_NULL, "failed indexedSetCreate(size = %d)", tdb_size); return NULL; } tdb->file = file; tdb->count = tdb->last = 0; tdb->minMsgTime = 1000.0; tdb->id = id; #ifdef LINUX if (channel) { if (!tdb->file) tdb->role = CLIENT; tdb->channel.r = channel->r; tdb->channel.w = channel->w; } #endif if (tdb->file) TDBread(tdb); return tdb; }
/* ======= Initialize the hash table ======= */ int HTinit (HTable *table) { table->terms=ATindexedSetCreate(PT_INITIALSIZE, 75); PTinit(&table->pointers); return 0; }
void SG_initMarks(void) { marks = ATindexedSetCreate(INITIAL_TABLE_SIZE, LOAD_PERCENTAGE); if (marks == NULL) { ATerror("SG_initMarks: unable to allocate table for marking."); } }
void CAESAR_INIT_GRAPH(void) { int argc; char **argv; char *FILENAME; char *OPTIONS; char *token; ATinitialize(0,NULL); ATsetWarningHandler(WarningHandler); ATsetErrorHandler(ErrorHandler); /* ATwarning ("Executing CAESAR_INIT_GRAPH"); */ FILENAME = getenv ("OPEN_CAESAR_FILE"); if (FILENAME == NULL) CAESAR_ERROR ("undefined environment variable $OPEN_CAESAR_FILE"); OPTIONS = getenv ("MCRL_OPTIONS"); if (OPTIONS == NULL) CAESAR_ERROR ("undefined environment variable $MCRL_OPTIONS"); #define MAX_OPTIONS 100 argv = (char**)calloc(MAX_OPTIONS,sizeof(char*)); argc = 0; argv[argc] = "mcrl_open"; // ATwarning ("%d -> \"%s\"\n", argc, argv [argc]); argc ++; /* skip leading white spaces */ while (*OPTIONS == ' ') OPTIONS++; token = strtok (OPTIONS, " "); while (1) { if (token == NULL) break; argv [argc] = token; // ATwarning ("%d -> \"%s\"\n", argc, argv [argc]); argc ++; token = strtok ((char *) NULL, " "); } argv [argc] = FILENAME; // ATwarning ("%d -> \"%s\"\n", argc, argv [argc]); argc ++; MCRLsetArguments(&argc, &argv); RWsetArguments(&argc,&argv); if (!MCRLinitialize()) ATerror("%s cannot be opened\n",FILENAME); ATwarning("Opened %s",FILENAME); RWinitialize(MCRLgetAdt()); LTSsetArguments(&argc,&argv); LTSinitialize(wrap_call_back); Label_set = ATindexedSetCreate(1024,75); /* ATwarning ("Leaving CAESAR_INIT_GRAPH"); */ }
ATbool AToccurs(ATerm var, ATerm t) { static char first_call=1; ATbool set_nonempty=ATfalse; ATbool occurs; if (first_call) { first_call=0; No_occurs=ATindexedSetCreate(16,40); } occurs = occurs_rec(var,t,&set_nonempty); if (set_nonempty) ATindexedSetReset(No_occurs); return occurs; }
static char unfold_solution(ATermSubst sigma) { /* - makes assigned, solution and equivalence empty - doesn't alter equivalence, except shortening find paths - returns 1: unifiable; sigma contains solution (except when NULL) - returns 0: not unifiable; sigma is empty Note: unfolding is also needed if sigma=NULL to detect loops. */ int i; ATerm t; char unifiable=1; static char first_call=1; if (first_call) { first_call = 0; loop_detection=ATindexedSetCreate(64,50); solution = ATtableCreate(64,50); } assert(ATisEmpty(ATtableKeys(solution))); for (i=ATstackDepth(assigned)-1;i>=0;i--) { ATerm x = ATstackPop(assigned); assert(ATisEmpty(ATindexedSetElements(loop_detection))); t = unfold_rec(find(x)); if (t && sigma) ATstackSet(sigma,ATgetInt((ATermInt)x),t); else { unifiable=0; break; } } ATtableReset(solution); ATtableReset(equivalence); if (unifiable) return ATtrue; else { ATstackReset(assigned); if (sigma) ATstackReset(sigma); return ATfalse; } }