void prob_client_destroy(prob_client_t pc) { RTfree(pc->file); RTfree(pc); pc = NULL; }
static void rel_load(FILE* f, vrel_t rel) { if (rel->bdd) sylvan_deref(rel->bdd); if (rel->vec_to_bddvar) RTfree(rel->vec_to_bddvar); if (rel->prime_vec_to_bddvar) RTfree(rel->prime_vec_to_bddvar); if (rel->variables) sylvan_deref(rel->variables); if (rel->prime_variables) sylvan_deref(rel->prime_variables); if (rel->all_variables) sylvan_deref(rel->all_variables); sylvan_serialize_fromfile(f); size_t bdd; fread(&bdd, sizeof(size_t), 1, f); rel->bdd = sylvan_ref(sylvan_serialize_get_reversed(bdd)); fread(&rel->vector_size, sizeof(size_t), 1, f); rel->vec_to_bddvar = (BDDVAR*)RTmalloc(sizeof(BDDVAR) * fddbits * rel->vector_size); rel->prime_vec_to_bddvar = (BDDVAR*)RTmalloc(sizeof(BDDVAR) * fddbits * rel->vector_size); fread(rel->vec_to_bddvar, sizeof(BDDVAR), rel->vector_size*fddbits, f); fread(rel->prime_vec_to_bddvar, sizeof(BDDVAR), rel->vector_size*fddbits, f); sylvan_gc_disable(); LACE_ME; rel->variables = sylvan_ref(sylvan_set_fromarray(rel->vec_to_bddvar, fddbits * rel->vector_size)); rel->prime_variables = sylvan_ref(sylvan_set_fromarray(rel->prime_vec_to_bddvar, fddbits * rel->vector_size)); rel->all_variables = sylvan_ref(sylvan_set_addall(rel->prime_variables, rel->variables)); sylvan_gc_enable(); }
void isba_destroy(isb_allocator_t buf) { do {remove_block(buf);} while (buf->num_block > 0); RTfree(buf->blocks); RTfree(buf); }
void lts_to_pg_solve (vset_t visited, int* src) { // converting the LTS to a symbolic parity game, save and solve. vset_destroy (true_states); vset_destroy (false_states); if (pg_output || pgsolve_flag) { rt_timer_t compute_pg_timer = RTcreateTimer (); RTstartTimer (compute_pg_timer); parity_game* g = compute_symbolic_parity_game (visited, src); RTstopTimer (compute_pg_timer); RTprintTimer (info, compute_pg_timer, "computing symbolic parity game took"); if (pg_output) { Print(info, "Writing symbolic parity game to %s.", pg_output); FILE* f = fopen (pg_output, "w"); spg_save (f, g); fclose (f); } if (pgsolve_flag) { spgsolver_options* spg_options = spg_get_solver_options (); rt_timer_t pgsolve_timer = RTcreateTimer (); Print(info, "Solving symbolic parity game for player %d.", spg_options->player); RTstartTimer (pgsolve_timer); recursive_result strategy; parity_game* copy = NULL; if (spg_options->check_strategy) { copy = spg_copy (g); } _Bool result = spg_solve (g, &strategy, spg_options); Print(info, " "); Print(info, "The result is: %s.", result ? "true" : "false"); RTstopTimer (pgsolve_timer); Print(info, " "); RTprintTimer (info, reach_timer, "reachability took "); RTprintTimer (info, compute_pg_timer, "computing game took "); RTprintTimer (info, pgsolve_timer, "solving took "); if (spg_options->strategy_filename != NULL) { Print(info, "Writing winning strategies to %s", spg_options->strategy_filename); FILE* f = fopen (spg_options->strategy_filename, "w"); result_save (f, strategy); fclose (f); } if (spg_options->check_strategy) { check_strategy (copy, &strategy, spg_options->player, result, 10); } } else { spg_destroy (g); } } if (player != 0) { RTfree (player); RTfree (priority); } }
/** * \brief Destroys vrels in the result and frees dynamically allocated arrays. */ void recursive_result_destroy(recursive_result result) { for (int p=0; p < 2; p++) { for (int i=0; i < result.strategy_levels_count[p]; i++) { vset_destroy(result.strategy_levels[p][i]); } RTfree(result.strategy_boundaries[p]); RTfree(result.strategy_levels[p]); } }
/** * Destroy a set. * The set must be created first with set_create */ static void set_destroy(vset_t set) { sylvan_deref(set->bdd); sylvan_deref(set->projection); sylvan_deref(set->variables); RTfree(set->vec_to_bddvar); RTfree(set); }
/** * Destroy a relation. */ static void rel_destroy(vrel_t rel) { sylvan_deref(rel->bdd); sylvan_deref(rel->variables); sylvan_deref(rel->prime_variables); sylvan_deref(rel->all_variables); RTfree(rel->vec_to_bddvar); RTfree(rel->prime_vec_to_bddvar); RTfree(rel); }
static void FIFOdestroy(stream_t *fifo_p){ stream_t fifo=*fifo_p; *fifo_p=NULL; void*tmp=fifo->read_block; while(tmp){ void*next=*((void**)tmp); RTfree(tmp); tmp=next; } RTfree(fifo); }
static void gzip_close_z(stream_t *stream,uint64_t orig_size){ int res; if ((*stream)->wr_buf) { do { if ((*stream)->compress) { res=deflate(&(*stream)->wr,Z_FINISH); } else { res=inflate(&(*stream)->wr,Z_FINISH); } if(res!=Z_OK && res!=Z_STREAM_END){ Abort("compression error %d %s",res,zError(res)); } int len=((*stream)->bufsize) - ((*stream)->wr.avail_out); if (len>0) { stream_write((*stream)->s,(*stream)->wr_buf,len); (*stream)->wr.next_out=(*stream)->wr_buf; (*stream)->wr.avail_out=(*stream)->bufsize; } } while (res!=Z_STREAM_END); if ((*stream)->compress) { res=deflateEnd(&(*stream)->wr); } else { res=inflateEnd(&(*stream)->wr); } switch(res){ case Z_OK: break; default: Abort("cleanup failed"); } RTfree((*stream)->wr_buf); } if ((*stream)->rd_buf) { if ((*stream)->compress) { res=inflateEnd(&(*stream)->rd); } else { res=deflateEnd(&(*stream)->rd); } switch(res){ case Z_OK: break; default: Abort("cleanup failed"); } RTfree((*stream)->rd_buf); } if (stream_writable(*stream)) { stream_close_z(&(*stream)->s,orig_size); } else { stream_close(&(*stream)->s); } RTfree (*stream); *stream=NULL; }
static size_t fifo_read_max(stream_t fifo,void*buf,size_t count){ if (fifo->blocks==1){ if (count < (fifo->write_idx-fifo->read_idx)){ // buffer will be non-empty after read. memcpy(buf,fifo->read_block+fifo->read_idx,count); fifo->read_idx+=count; return count; } else { // buffer will be empty after read. int len=fifo->write_idx-fifo->read_idx; memcpy(buf,fifo->read_block+fifo->read_idx,len); fifo->read_idx=sizeof(void*); fifo->write_idx=sizeof(void*); return len; } } else { if (count < (fifo->blocksize-fifo->read_idx)){ // buffer will be non-empty after read. memcpy(buf,fifo->read_block+fifo->read_idx,count); fifo->read_idx+=count; return count; } else { // buffer will be empty after read. int len=fifo->blocksize-fifo->read_idx; memcpy(buf,fifo->read_block+fifo->read_idx,len); void*tmp=fifo->read_block; fifo->read_block=*((void**)tmp); RTfree(tmp); fifo->blocks--; fifo->read_idx=sizeof(void*); return len+fifo_read_max(fifo,buf+len,count-len); } } }
void SIdeleteC(string_index_t si,const char*str,int len){ uint32_t hash; int bucket; int idx,next,deleted; hash=SuperFastHash(str,len,0); bucket=hash&si->mask; idx=si->table[bucket]; si->table[bucket]=END_OF_LIST; while(idx!=END_OF_LIST){ if (0==strcmp(str,si->data[idx])) { deleted=idx; RTfree(si->data[idx]); si->count--; idx=si->next[idx]; while(idx!=END_OF_LIST){ next=si->next[idx]; si->next[idx]=si->table[bucket]; si->table[bucket]=idx; idx=next; } add_to_free_list(si,deleted); return; } else { next=si->next[idx]; si->next[idx]=si->table[bucket]; si->table[bucket]=idx; idx=next; } } }
/*! * @param buf the buffer to remove a memory block from */ static void remove_block(isb_allocator_t buf) { Debug("freeing block %zu", buf->num_block-1); buf->num_block--; RTfree(buf->blocks[buf->num_block]); }
void trc_find_and_write (trc_env_t *env, char *trc_output, ref_t dst_idx, int level, ref_t *parent_ofs, ref_t start_idx) { rt_timer_t timer = RTcreateTimer (); RTstartTimer (timer); /* Other workers may have influenced the trace, writing to parent_ofs. * we artificially limit the length of the trace to 10 times that of the * found one */ size_t max_length = level * 10; ref_t *trace = RTmalloc(sizeof(ref_t) * max_length); if (trace == NULL) Abort("unable to allocate memory for trace"); int i = max_length - 1; ref_t curr_idx = dst_idx; trace[i] = curr_idx; while(curr_idx != start_idx) { i--; if (i < 0) Abort("Trace length 10x longer than initially found trace. Giving up."); curr_idx = parent_ofs[curr_idx]; trace[i] = curr_idx; } Warning (info, "reconstructed trace length: %zu", max_length - i); RTstopTimer (timer); RTprintTimer (info, timer, "constructing the trace took"); trc_write_trace (env, trc_output, &trace[i], max_length - i); RTfree (trace); }
void event_queue_destroy(event_queue_t *queue){ for(int i=0;i<(*queue)->pending;i++){ MPI_Cancel(&(*queue)->request[i]); } destroy_manager ((*queue)->man); RTfree(*queue); *queue=NULL; }
void cndfs_global_deinit (run_t *run, wctx_t *ctx) { if (run->shared->rec != NULL) { alg_global_deinit (run->shared->rec, ctx->global->rec); wctx_destroy (ctx->global->rec); } RTfree (ctx->global); }
stream_t arch_read_raw(archive_t archive,char *name,char**code){ if (archive->procs.flags&ARCH_TRANSPARENT_COMPRESSION){ stream_t s=archive->procs.read_raw(archive,name,NULL); char*hdr=DSreadSA(s); if (code) *code=hdr; else RTfree(hdr); return s; } else { return archive->procs.read_raw(archive,name,code); } }
int receive_number(zmsg_t *response) { char *nr_s = zmsg_popstr(response); int nr; int rc = sscanf(nr_s, "%d", &nr); assert(rc == 1); (void) rc; RTfree(nr_s); return nr; }
void tarjan_local_deinit (run_t *run, wctx_t *ctx) { alg_local_t *loc = ctx->local; dfs_stack_destroy (loc->search_stack); dfs_stack_destroy (loc->tarjan_stack); fset_free (loc->visited_states); RTfree (loc); (void) run; }
void ndfs_local_deinit (run_t *run, wctx_t *ctx) { alg_local_t *loc = ctx->local; if (all_red) bitvector_free (&loc->stackbits); bitvector_free (&loc->color_map); dfs_stack_destroy (loc->stack); RTfree (loc); (void) run; }
void do_output(char *etf_output, vset_t visited) { FILE *tbl_file; rt_timer_t timer = RTcreateTimer(); RTstartTimer(timer); Warning(info, "writing output"); tbl_file = fopen(etf_output, "w"); if (tbl_file == NULL) AbortCall("could not open %s", etf_output); if (vdom_separates_rw(domain)) { /* * This part is necessary because the ETF format does not yet support * read, write and copy. This part should thus be removed when ETF is * extended. */ Warning(info, "Note: ETF format does not yet support read, write and copy."); transitions_short = GBgetTransitionsShort; RTfree (r_projs); RTfree (w_projs); w_projs = r_projs = (ci_list **) dm_rows_to_idx_table (GBgetDMInfo(model)); for (int i = 0; i < nGrps; i++) { vset_destroy(group_explored[i]); group_explored[i] = vset_create(domain, r_projs[i]->count, r_projs[i]->data); vset_project(group_explored[i], visited); } } output_init(tbl_file); output_trans(tbl_file); output_lbls(tbl_file, visited); output_types(tbl_file); fclose(tbl_file); RTstopTimer(timer); RTprintTimer(info, timer, "writing output took"); }
static void dbg_found_read_dep_error (check_ctx_t *ctx, int *dst, int *dst2, int idx) { char *res = RTmalloc (1024); lts_type_t ltstype = GBgetLTStype (ctx->parent); int typeno = lts_type_get_state_typeno (ltstype, idx); print_chunk (ctx->parent, res, 1024, typeno, dst[idx]); Print1 (lerror, "Found missing read dependency in group %d (diff slot: %d -- %s != %s).\\" "Identifying culprit read slot...", ctx->group, idx, str_slot(ctx, dst2, idx), res); RTfree (res); }
void SIreset(string_index_t si){ int i,N; N=array_size(si->man); for(i=0;i<N;i++) { if (USED(si,i)) RTfree(si->data[i]); } si->count=0; si->free_list=END_OF_LIST; expand_free_list(si,0,N); N=si->mask+1; for(i=0;i<N;i++) si->table[i]=END_OF_LIST; }
void permute_free (permute_t *perm) { RTalignedFree (perm->tosort); if (Perm_Otf == perm->permutation) RTalignedFree (perm->pad); if (Perm_Random == perm->permutation) { for (size_t i = 0; i < K+TODO_MAX; i++) RTalignedFree (perm->rand[i]); RTfree (perm->rand); } if ( Perm_RR == perm->permutation || Perm_SR == perm->permutation || Perm_Dynamic == perm->permutation ) { RTalignedFree (perm->rand[0]); RTalignedFree (perm->rand); } if (act_detect || files[1] || (PINS_BUCHI_TYPE == PINS_BUCHI_TYPE_TGBA)) { for (size_t i = 0; i < K+TODO_MAX; i++) { RTfree (perm->todos[i].ti.labels); } } RTalignedFree (perm->todos); RTalignedFree (perm); }
void start_ltsmin(void) { prob_client_t pc = prob_client_create(); ProBInitialResponse initial_resp = prob_init(pc, 0); // Some Demo code /* Get the successors of the initial state. DA$init_state is the transition group representing the initialization. The prototype does initializing and constant setup in one step. I don't know how LTSmin handles this, but DA$init_state is always the only transition group that is possible in the initial state and it is never possible to execute DA$init_state in any other state. ProB automatically adds it as the first transition group. */ int nr_successors; ProBState *successors = prob_next_state(pc, initial_resp.initial_state, "DA$init_state", &nr_successors); prob_destroy_initial_response(&initial_resp); // Send a get label request using the last state of the previous request ProBState foo = successors[nr_successors - 1]; // DAinvariant is hard wired because I am too lazy to store it in the init code. // However, ProB does send the state label. int val = prob_get_state_label(pc, foo, "DAinvariant"); printf("Result: %d\n", val); prob_terminate(pc); // Cleanup int i; for (i = 0; i < nr_successors; i++) { prob_destroy_state(&(successors[i])); } RTfree(successors); prob_client_destroy(pc); }
void SIdestroy(string_index_t *si){ int i; int size=array_size((*si)->man); for(i=0;i<size;i++){ if (USED(*si,i)) RTfree((*si)->data[i]); } RTfree((*si)->len); RTfree((*si)->data); RTfree((*si)->next); RTfree((*si)->table); RTfree(*si); *si=NULL; }
static inline void print_ti (check_ctx_t *ctx, transition_info_t *ti) { if (ti == NULL || ti->labels == NULL) return; model_t model = ctx->parent; lts_type_t ltstype = GBgetLTStype (model); int Max = 4096; char *tmp = RTmalloc (Max); int l; for (int i = 0; i < ctx->L; i++) { char *name = lts_type_get_edge_label_name (ltstype, i); char *type = lts_type_get_edge_label_type (ltstype, i); int typeno = lts_type_get_edge_label_typeno (ltstype, i); char *res = tmp; l = snprintf (res, Max, " --> %s : %s = ", name, type); l += print_chunk (model, res+l, Max-l, typeno, ti->labels[i]); Printf (lerror, "%s\n", res); } RTfree (tmp); }
void prob_get_label_group(prob_client_t pc, ProBState s, int group, int *res) { zmsg_t *request = zmsg_new(); zmsg_addstr(request, "get-state-label-group"); zmsg_addstrf(request, "%d", pc->id_count); zmsg_addstrf(request, "DA%d", group); prob_put_state(request, s); zmsg_send(&request, pc->zocket); zmsg_destroy(&request); zmsg_t *response = zmsg_recv(pc->zocket); drop_frame(response); drop_frame(response); char *result_s; for (int i = 0; (result_s = zmsg_popstr(response)) != NULL; i++) { int r; sscanf(result_s, "%d", &r); res[i] = r; RTfree(result_s); } zmsg_destroy(&response); }
int prob_get_state_label(prob_client_t pc, ProBState s, char *label) { zmsg_t *request = zmsg_new(); zmsg_addstr(request, "get-state-label"); zmsg_addstrf(request, "%d", pc->id_count); zmsg_addstrf(request, "DA%s", label); prob_put_state(request, s); zmsg_send(&request, pc->zocket); zmsg_destroy(&request); zmsg_t *response = zmsg_recv(pc->zocket); drop_frame(response); drop_frame(response); char *result_s = zmsg_popstr(response); int res; sscanf(result_s, "%d", &res); RTfree(result_s); zmsg_destroy(&response); return res; }
static ProBState * prob_next_x(prob_client_t pc, ProBState s, char *transitiongroup, int *size, char *header) { zmsg_t *request = zmsg_new(); zmsg_addstr(request, header); zmsg_addstrf(request, "%d", pc->id_count); zmsg_addstr(request, transitiongroup); prob_put_state(request, s); Debugf("requesting next-state, contents:\n"); #ifdef LTSMIN_DEBUG if (log_active(debug)) zmsg_print(request); #endif zmsg_send(&request, pc->zocket); zmsg_destroy(&request); zmsg_t *response = zmsg_recv(pc->zocket); Debugf("response for next-state, contents:\n"); #ifdef LTSMIN_DEBUG if (log_active(debug)) zmsg_print(response); #endif drop_frame(response); drop_frame(response); char *nr_of_states_s = zmsg_popstr(response); sscanf(nr_of_states_s, "%d", size); RTfree(nr_of_states_s); ProBState *successors = RTmalloc(sizeof(ProBState) * (*size)); int i; for (i = 0; i < (*size); i++) { successors[i] = prob_get_state(response); } zmsg_destroy(&response); return successors; }
void ci_free (ci_list *list) { RTfree (list); }