void AssocContainCanvas::remove(bool from_model) { if (!from_model) { if (the_canvas()->must_draw_all_relations()) { const AssocContainCanvas * a = this; while (a->begin->type() == UmlArrowPoint) { a = (AssocContainCanvas *) ((ArrowPointCanvas *) a->begin)->get_other(a); if (a == 0) break; } if (a && !a->begin->isSelected() && !a->begin->get_bn()->deletedp()) { a = this; while (a->end->type() == UmlArrowPoint) { a = (AssocContainCanvas *) ((ArrowPointCanvas *) a->end)->get_other(a); if (a == 0) break; } if (a && !a->end->isSelected() && !a->end->get_bn()->deletedp()) { msg_warning("Bouml", TR("<i>Draw all relations</i> forced to <i>no</i>")); the_canvas()->dont_draw_all_relations(); } } } delete_it(); } else get_start()->unassociate(get_end()); // line will be deleted }
static void stats_print_diff(struct stats_file *file) { struct stats_record *begin, *end; begin = get_begin(file); begin = get_next(file, begin); end = get_end(file); printf("\n(begin + 1)\n"); printf("\t[%04d] ", get_index(file, begin)); stats_print_record(begin); printf("end\n"); printf("\t[%04d] ", get_index(file, end)); stats_print_record(end); if (file->home_first && get_home(file)) { printf("\nhome\n"); stats_print_rec_diff(file->home_first, get_home(file)); } if (file->roaming_first && get_roaming(file)) { printf("\roaming\n"); stats_print_rec_diff(file->roaming_first, get_roaming(file)); } }
// Reads data from the IO, according to the Rack specifications for `#read`. static VALUE tfio_read(int argc, VALUE *argv, VALUE self) { int fd = get_tmpfile(self); size_t pos = get_pos(self); size_t end = get_end(self); VALUE buffer = Qnil; char ret_nil = 0; ssize_t len = 0; // get the buffer object if given if (argc == 2) { Check_Type(argv[1], T_STRING); buffer = argv[1]; } // get the length object, if given if (argc > 0 && argv[0] != Qnil) { Check_Type(argv[0], T_FIXNUM); len = FIX2LONG(argv[0]); if (len < 0) rb_raise(rb_eRangeError, "length should be bigger then 0."); ret_nil = 1; } // return if we're at the EOF. if (pos == end) goto no_data; // calculate length if it wasn't specified. if (len == 0) { // make sure we're not reading more then we have len = end - pos; // set position for future reads set_pos(self, end); if (len == 0) goto no_data; } else { // set position for future reads set_pos(self, pos + len); } // limit read to what we have if (len + pos > end) len = end - pos; // create the buffer if we don't have one. if (buffer == Qnil) { buffer = rb_str_buf_new(len); // make sure the buffer is binary encoded. rb_enc_associate(buffer, BinaryEncoding); } else { // make sure the buffer is binary encoded. rb_enc_associate(buffer, BinaryEncoding); if (rb_str_capacity(buffer) < len) rb_str_resize(buffer, len); } // read the data. if (pread(fd, RSTRING_PTR(buffer), len, pos) <= 0) goto no_data; rb_str_set_len(buffer, len); return buffer; no_data: if (ret_nil) return Qnil; else return rb_str_buf_new(0); }
/** Gets returns a line. this is okay for small lines, but shouldn't really be used. Limited to ~ 1Mb of a line length. */ static VALUE tfio_gets(VALUE self) { int fd = get_tmpfile(self); size_t pos = get_pos(self); size_t end = get_end(self); if (pos == end) return Qnil; size_t pos_e = pos; char c; int ret; VALUE buffer; do { ret = pread(fd, &c, 1, pos_e); } while (ret > 0 && c != '\n' && (++pos_e < end)); set_pos(self, pos_e + 1); if (pos > pos_e) { buffer = rb_str_buf_new(pos_e - pos); // make sure the buffer is binary encoded. rb_enc_associate(buffer, BinaryEncoding); if (pread(fd, RSTRING_PTR(buffer), pos_e - pos, pos) < 0) return Qnil; rb_str_set_len(buffer, pos_e - pos); return buffer; } return Qnil; }
static int start_end(char *line, t_env *e) { if (!ft_strcmp(line, "start")) { if (!e->start) { get_start(e); e->start = 1; return (1); } else return (ft_putstr_error("Error, multiple start.\n")); } else if (!ft_strcmp(line, "end")) { if (!e->end) { get_end(e); e->end = 1; return (1); } else return (ft_putstr_error("Error, multiple end.\n")); } else return (ft_putstr_error("Error, bad comment.\n")); }
static bool coalesce_blocks(void *ptr1, void *ptr2) { void *tmpptr = Min(ptr1, ptr2); Size new_size; void *next; ptr2 = Max(ptr1, ptr2); ptr1 = tmpptr; if (get_end(ptr1) != get_header(ptr2)) return false; Assert(get_next(ptr1) == ptr2); Assert(!is_allocated(ptr1)); Assert(!is_allocated(ptr2)); new_size = get_size(ptr1) + BLOCK_SIZE(get_size(ptr2)); get_header(ptr1)->size = new_size; /* Mark ptr2 as no longer an ICE BOODA. */ get_header(ptr2)->magic = 0; next = get_next(ptr2); set_next(ptr1, next); if (next) set_prev(next, ptr1); return true; }
char *get_next_line(const int fd) { static char *save = ""; char *buffer; int j; int nbread; j = -1; if ((buffer = malloc(sizeof(char) * READ_SIZE + 1)) == NULL) return (NULL); if (save == NULL) return (NULL); if ((nbread = read(fd, buffer, READ_SIZE)) == -1) return (NULL); buffer[nbread] = '\0'; save = my_strcatg(save, buffer); while (save[++j] != '\0') { if (save[j] == '\n') { save[j] = '\0'; buffer = my_strcpy(save); save = &save[j + 1]; return (buffer); } } return(get_end(buffer, save, nbread, fd)); }
static void stats_hdr_info(struct stats_file *file) { struct stats_file_header *hdr; struct stats_record *begin, *end, *home, *roaming; unsigned int home_idx, roaming_idx; hdr = get_hdr(file); begin = get_begin(file); end = get_end(file); home = get_home(file); if (!home) home_idx = UINT_MAX; else home_idx = get_index(file, home); roaming = get_roaming(file); if (!roaming) roaming_idx = UINT_MAX; else roaming_idx = get_index(file, roaming); printf("Data Structure Sizes\n"); printf(" sizeof header %zd/0x%02zx\n", sizeof(struct stats_file_header), sizeof(struct stats_file_header)); printf(" sizeof entry %zd/0%02zx\n\n", sizeof(struct stats_record), sizeof(struct stats_record)); printf("File\n"); printf(" addr %p\n", file->addr); printf(" len %zd\n", file->len); printf(" max nr entries %d\n", file->max_nr); printf(" nr entries %d\n\n", file->nr); printf("Header\n"); printf(" magic 0x%08x\n", hdr->magic); printf(" begin [%d] 0x%08x\n", get_index(file, begin), hdr->begin); printf(" end [%d] 0x%08x\n", get_index(file, end), hdr->end); printf(" home [%d] 0x%08x\n", home_idx, hdr->home); printf(" roaming [%d] 0x%08x\n\n", roaming_idx, hdr->roaming); printf("Pointers\n"); printf(" hdr %p\n", hdr); printf(" begin %p\n", begin); printf(" end %p\n", end); printf(" home %p\n", home); printf(" romaing %p\n", roaming); printf(" first %p\n", file->first); printf(" last %p\n\n", file->last); }
//---------------------------------------------------------------------------- // CTmTimerList::pop // Purpose : Pop the first element off the timer list. This also removes it // from the list. //---------------------------------------------------------------------------- CTmTimerEvent * CTmTimerList::pop(CTmTime *pp_time) { CTmTimerEvent *lp_event = (CTmTimerEvent *) get_first(); if (lp_event) pp_time->set(curr_key()); else pp_time->set(0); int lv_count = count(curr_key()); get_end(); // Avoiding tracing here for efficiency if (lp_event) { //7/8/10 Temporary code to catch duplicates if (lv_count > 1) { TMTIME_TRACE(5, XATM_TraceTimer, ("CTmTimerList::pop : DUPLICATE KEY DETECTED. count=%d\n", lv_count)); CTmTimerEvent * lp_ev = (CTmTimerEvent *) get_first(); for (int lv_idx=0;lv_idx < lv_count; lv_idx++) { TMTIME_TRACE(5, XATM_TraceTimer, ("CTmTimerList::pop : DUPLICATE KEY DETECTED. %d: key " PFLL ", cmd %d, ID %d\n", lv_idx, curr_key(), lp_ev->command(), ((lp_ev->transaction())?lp_ev->transaction()->seqnum():-1))); lp_ev = (CTmTimerEvent *) get_next(); } get_end(); } CTmTimerEvent *lp_removedEvent = (CTmTimerEvent *) remove_first((pp_time->get())); if (lp_event != lp_removedEvent) { TMTIME_TRACE(1, XATM_TraceError, ("CTmTimerList::pop : PROGRAMMING ERROR! first event %p doesn't match removed event %p.\n", (void *) lp_event, (void *) lp_removedEvent)); abort(); } TMTIME_TRACE(5, XATM_TraceTimer, ("CTmTimerList::pop : EXIT event %p, inputTime %d, returnTime " PFLL ".\n", (void *) lp_event, lp_event->wakeupInterval(), pp_time->get())); } else { TMTIME_TRACE(5, XATM_TraceTimer, ("CTmTimerList::pop : EXIT Timer list empty, returnTime " PFLL ".\n", pp_time->get())); } return lp_event; } // CTmTimerList::pop
void Nwindow::print_line(string line, COLOR c){ int aspace = get_end(line); int bspace = get_start(line); //assert(bspace >= 0 && aspace >= 0); int prev_x = pos_x; move(pos_y,pos_x + bspace); print_color(line.substr(bspace,line.length() - aspace),c); move(pos_y +1,prev_x); }
double get_strength(Bond bond) { Site pos = bond.first; short int direction = bond.second; if(direction < 2) { return lattice[pos].bonds[direction]; } return lattice[get_end(bond)].bonds[direction-2]; }
int zero_out(const char *fname){ FILE *f; if(!(f = fopen(fname,"r+b"))){ printf("Couldn't open %s for writing",fname); } int end = get_end(fname); for(int i = 0; i < end;i++) fputc(0,f); fclose(f); return 1; }
int zero_out(char *file){ int end = get_end(file); FILE *f = fopen(file,"wb"); if(!(f)) return -1; int i = 0; while(i < end){ fputc(0x00,f); i++; } return 0; }
void init_domain (float ** domain_ptr,int rank) { int i,j,start,end,rows; start = get_start(rank); end = get_end(rank); rows = get_num_rows(rank); for (j=start;j<end;j++) { for (i=0;i<(int)floor(WIDTH/H);i++) { domain_ptr[j-start][i] = 0.0; } } }
void add_new_Bonds(Site & inv_site) { Bond new_bond; for(short int dir=0; dir < 4; dir++) { new_bond = std::make_pair(inv_site, dir); if(!lattice.at(get_end(new_bond)).is_invaded) { accessible_Bonds.insert(std::make_pair(get_strength(new_bond), new_bond)); } } }
void find_next_valid_item() { // if low_itr is at the end of current container, go to next container while (m_low_itr == get_end(*m_high_itr)) { ++m_high_itr; if (m_high_itr == m_high_end_itr) { // We reached the end! Set low_itr to invalid and return m_low_itr = LowLevelItrType(); return; } m_low_itr = get_begin(*m_high_itr); } }
/** Gets returns a line. this is okay for small lines, but shouldn't really be used. Limited to ~ 1Mb of a line length. */ static VALUE strio_gets(VALUE self) { char *str = get_str(self); size_t pos = get_pos(self); size_t end = get_end(self); if (str == NULL || pos == end) return Qnil; size_t pos_e = pos; while ((pos_e < end) && str[pos_e] != '\n') pos_e++; set_pos(self, pos_e + 1); return rb_enc_str_new(str + pos, pos_e - pos, BinaryEncoding); }
/* * 克鲁斯卡尔(Kruskal)最小生成树 */ void kruskal(Graph G) { int i,m,n,p1,p2; int length; int index = 0; // rets数组的索引 int vends[MAX]={0}; // 用于保存"已有最小生成树"中每个顶点在该最小树中的终点。 EData rets[MAX]; // 结果数组,保存kruskal最小生成树的边 EData *edges; // 图对应的所有边 // 获取"图中所有的边" edges = get_edges(G); // 将边按照"权"的大小进行排序(从小到大) sorted_edges(edges, G.edgnum); for (i=0; i<G.edgnum; i++) { p1 = get_position(G, edges[i].start); // 获取第i条边的"起点"的序号 p2 = get_position(G, edges[i].end); // 获取第i条边的"终点"的序号 m = get_end(vends, p1); // 获取p1在"已有的最小生成树"中的终点 n = get_end(vends, p2); // 获取p2在"已有的最小生成树"中的终点 // 如果m!=n,意味着"边i"与"已经添加到最小生成树中的顶点"没有形成环路 if (m != n) { vends[m] = n; // 设置m在"已有的最小生成树"中的终点为n rets[index++] = edges[i]; // 保存结果 } } free(edges); // 统计并打印"kruskal最小生成树"的信息 length = 0; for (i = 0; i < index; i++) length += rets[i].weight; printf("Kruskal=%d: ", length); for (i = 0; i < index; i++) printf("(%c,%c) ", rets[i].start, rets[i].end); printf("\n"); }
void Kruskal(LGraph G) { int p1, p2; int m, n; int index = 0; int vends[MAXN] = {0}; //用于保存"已有最小生成树"中每个顶点在该最小树中的终点。 //for ex:已经有一条边AB了,那么vends[A.pos] = B.pos EData rets[MAXN]; //结果数组,保存生成树的边 EData *edges; //图对应的所有边 edges = get_edges(G); sort_edges(edges, G.edgnum); for (int i = 0; i < G.edgnum; ++i) { p1 = getPos(G, edges[i].start); p2 = getPos(G, edges[i].end); m = get_end(vends, p1); n = get_end(vends, p2); //m != n说明没有形成环 if (m != n) { vends[m] = n; rets[index++] = edges[i]; } } free(edges); int length = 0; for (int i = 0; i < index; ++i) length += rets[i].weight; printf("Kruskal = %d: ", length); for (int i = 0; i < index; ++i) printf("(%c, %c) ", rets[i].start, rets[i].end); printf("\n"); }
static void update_nr_entries(struct stats_file *file) { struct stats_record *begin, *end; int nr; begin = get_begin(file); end = get_end(file); nr = get_index(file, end) - get_index(file, begin); if (nr < 0) nr += file->max_nr; file->nr = nr; }
static int count_word(char *str, char c) { char *s; int count; s = get_begin(str, c); count = 0; while (*s != '\0') { s = get_end(s, c); s = get_begin(s, c); count++; } return (count); }
static int append_record(struct stats_file *file, struct stats_record *rec) { struct stats_record *cur, *next; int err; if (file->last == get_end(file)) { err = stats_file_remap(file, file->len + sysconf(_SC_PAGESIZE)); if (err < 0) return err; stats_file_update_cache(file); } cur = get_end(file); next = get_next(file, cur); memcpy(next, rec, sizeof(struct stats_record)); set_end(file, next); return 0; }
bool invade_bond(Bond & inv_bond) { Site inv_site = get_end(inv_bond); if (lattice.at(inv_site).is_invaded) { trappedBonds.push_back(inv_bond); return true; } else { cluster.push_back(inv_bond); lattice.at(inv_site).is_invaded = true; add_new_Bonds(inv_site); } return false; }
void* precomp_pthread_func(void* args) { precomp_thread_args targs = get_data(precomp_thread_args,args); int** mat = targs.mat; int** ps = targs.ps; int dim = targs.dim; for(int j=get_start(args); j<get_end(args); j++) { ps[0][j] = mat[0][j]; for (int i=1; i<dim; i++) { ps[i][j] = ps[i-1][j] + mat[i][j]; } } }
float get_convergence_sqd (float ** current_ptr,float ** next_ptr,int rank) { int i,j,my_start,my_end,my_num_rows; float sum; my_start = get_start(rank); my_end = get_end(rank); my_num_rows = get_num_rows(rank); sum = 0.0; for (j=my_start;j<=my_end;j++) { for (i=0;i<(int)floor(WIDTH/H);i++) { sum += pow(next_ptr[global_to_local(rank,j)][i]-current_ptr[global_to_local(rank,j)][i],2); } } return sum; }
int main(int argc, char *argv[]) { int e; int f=3333; static int g; static int h=4444; printf("program text (etext) %p\n", (void*)get_etext()); printf("initialized data (edata) %p\n", (void*)get_edata()); printf("uninitialized data (end) %p\n", (void*)get_end()); printf("&e=%p\n", &e); printf("&f=%p\n", &f); printf("&g=%p\n", &g); printf("&h=%p\n", &h); printf("This test is only for Apple Mac\n"); return 0; }
float get_val_par (float * above_ptr,float ** domain_ptr,float * below_ptr,int rank,int i,int j) { float ret_val; int p; MPI_Comm_size(MPI_COMM_WORLD,&p); /* enforce bc's first */ if(i == ((int)floor(WIDTH/H/2)-1) && j == 0) { /* This is the heat source location */ ret_val = T_SRC0; } else if (i <= 0 || j <= 0 || i >= ((int)floor(WIDTH/H)-1) || j >= ((int)floor(HEIGHT/H)-1)) { /* All edges and beyond are set to 0.0 */ ret_val = 0.0; } else { /* Else, return value for matrix supplied or ghost rows */ if (j < get_start(rank)) { if (rank == ROOT) { /* not interested in above ghost row */ ret_val = 0.0; } else { ret_val = above_ptr[i]; /*printf("%d: Used ghost (%d,%d) row from above = %f\n",rank,i,j,above_ptr[i]); fflush(stdout);*/ } } else if (j > get_end(rank)) { if (rank == (p-1)) { /* not interested in below ghost row */ ret_val = 0.0; } else { ret_val = below_ptr[i]; /*printf("%d: Used ghost (%d,%d) row from below = %f\n",rank,i,j,below_ptr[i]); fflush(stdout);*/ } } else { /* else, return the value in the domain asked for */ ret_val = domain_ptr[global_to_local(rank,j)][i]; /*printf("%d: Used real (%d,%d) row from self = %f\n",rank,i,global_to_local(rank,j),domain_ptr[global_to_local(rank,j)][i]); fflush(stdout);*/ } } return ret_val; }
main(int argc, char **argv) { #ifdef __APPLE__ char end = get_end(); #else extern char end; #endif char *sbrk(int); fflush(stdout); initializeStuff(argc, argv); yyparse(); finishUp(); if (emitPrint) printf("storage high water mark 0x%x == %d\n", sbrk(0) - &end, sbrk(0) - &end); if (errorFlag) chokePukeAndDie(); else exit(0); }
inline static int lua_fastsearch_wrap(lua_State *L, int mode) { size_t string_len; const char *string = luaL_checklstring(L, 1, &string_len); size_t token_len; const char *token = luaL_checklstring(L, 2, &token_len); int nargs = lua_gettop(L); int start = get_start(L, nargs, string_len); int end = get_end(L, nargs, string_len); if (start > end){ return -1; } string_len = end - start; int val = fastsearch(string + start, string_len, token, token_len, -1, mode); if (mode == FAST_COUNT) { return val; } if(val == -1) { return val; } int r = val + ((start > 0) ? start : 0); return r; }
//---------------------------------------------------------------------------- // CTmTimerList::getFirst // Purpose : Get the time of the first entry on the timer list. // The CTmTime returned is the wakeup time(since EPOC) - TMSTARTTIME. //---------------------------------------------------------------------------- CTmTime CTmTimerList::getFirst() { CTmTime lv_time(0); CTmTimerEvent *lp_event = (CTmTimerEvent *) get_first(); if (lp_event) lv_time.set(curr_key()); get_end(); // Avoiding tracing here for efficiency if (lp_event) { TMTIME_TRACE(5, XATM_TraceTimer, ("CTmTimerList::getFirst : EXIT event %p, inputTime %d, returnTime " PFLL ".\n", (void *) lp_event, lp_event->wakeupInterval(), lv_time.get())); } else { TMTIME_TRACE(5, XATM_TraceTimer, ("CTmTimerList::getFirst : EXIT event list empty, returnTime " PFLL ".\n", lv_time.get())); } return lv_time; } // CTmTimerList::getFirst