void check_md5(rainbow_t *r, string_table_t *table) { /* Check for an existing bucket */ for (int i = 0; i < ENTRY_SIZE; i++) { md5_binary_t *binary = &r->hashes[i], *start; unsigned int bucket = calc_bucket_binary(binary); uint32_t s = array[bucket]; /* If its an empty bucket, just bail */ if (likely(s == UINT32_MAX)) continue; /* If we have a stored top and it doesn't match, continue */ if (get_top(s) && (calc_top_binary(binary) != get_top(s))) continue; /* Search for a match */ for (start = hash_buff + remove_top(s); start->r64[0] < binary->r64[0]; start++) { } for (; start->r64[0] == binary->r64[0]; start++) { if (start->r64[1] == binary->r64[1]) { print_found(r, i, table); start->r64[1] = 0; __sync_fetch_and_add(&match, 1); break; } } } }
//--------------------------------------------------------------------------------------- LUnits GmoBox::get_content_top() { ImoStyle* pStyle = get_style(); if (pStyle) return get_top() + pStyle->margin_top() + pStyle->border_width_top() + pStyle->padding_top(); else return get_top(); }
void pop_to_init (Stack stacks[N], int locations[N], int a) { int pos = locations[a]; int cur = get_top (&stacks[pos]); while (cur != a) { cur = pop (&stacks[pos]); push (&stacks[ cur ], cur); locations [cur] = cur; cur = get_top (&stacks[pos]); } }
static int validate(Dlist *dl) { Dlist_data *i; for (i = get_top(dl); i && i != get_head(dl); i = i->next); if (i != get_head(dl)) return 0; for (i = get_head(dl); i && i != get_top(dl); i = i->prev); if (i != get_top(dl)) return 0; return 1; }
int pop(unsigned int *stack) { if (get_top()==0) { printf("stack underflow\n"); return UNDERFLOW; } else { dec_top(); return stack[get_top()]; } return 0; }
css_error css__compose_top(const css_computed_style *parent, const css_computed_style *child, css_computed_style *result) { css_fixed length = 0; css_unit unit = CSS_UNIT_PX; uint8_t type = get_top(child, &length, &unit); if (type == CSS_TOP_INHERIT) { type = get_top(parent, &length, &unit); } return set_top(result, type, length, unit); }
int EvaluateExpression(){ int n; int flag; int c; char x,theta; int a,b; char OP[]="+-*/()#"; SqStack OPTR; SqStack OPND; init_stack(&OPTR); push(&OPTR,'#'); init_stack(&OPND); flag=getNext(&c); get_top(OPTR, &x); while(c!='#' || x != '#') { if(flag == 0) { push(&OPND,c); flag = getNext(&c); } else { get_top(OPTR, &x); switch(Precede(x, c)) { case '<'://栈顶元素优先级低 push(&OPTR,c); flag = getNext(&c); break; case '='://脱括号并接受下一字符 pop(&OPTR,&x); flag = getNext(&c); break; case '>':// 退栈并将运算结果入栈 pop(&OPTR, &theta); pop(&OPND,&b); pop(&OPND,&a); push(&OPND, Operate(a, theta, b)); break; } } get_top(OPTR, &x); } get_top(OPND, &c); return c; }
int func(int count, int len){ if(count == len-1){ return 0; } if(input[count] == '[' || input[count] == '('){ printf("dsfsd\n"); printf("%d\n", count); push(input[count]); if(input[count + 1] == '[' || input[count + 1] == '('){ if(input[count] == '('){ return 2 * func(count+1, len); } else{ return 3 * func(count+1, len); } } else{ if(input[count] == '('){ return 2 + func(count+1, len); } else{ return 3 + func(count+1, len); } } } else if(input[count] == ')'){ printf("dsfsd2\n"); char temp = get_top(); if(temp == '('){ pop(); } else{ return 1; } } else if(input[count] == ']'){ char temp = get_top(); if(temp == '['){ pop(); } else{ return 1; } } }
/** * \brief Align the other item of the collision on the right of \a this. * \param info Some informations about the collision. * \param pos The bottom left position to put the other item at. * \param policy The description of how to align the items. */ bool bear::universe::physical_item::collision_align_right ( const collision_info& info, const position_type& pos, const collision_align_policy& policy ) { bool result(false); if ( collision_align_at(info.other_item(), pos) ) { result = true; physical_item& that = info.other_item(); switch ( policy.get_contact_mode() ) { case contact_mode::full_contact: that.set_left_contact(); set_right_contact(); break; case contact_mode::range_contact: that.set_left_contact( get_bottom(), get_top() ); set_right_contact( that.get_bottom(), that.get_top() ); break; case contact_mode::no_contact: // nothing to do break; } info.get_collision_repair().set_contact_normal (info.other_item(), vector_type(1, 0)); } return result; } // physical_item::collision_align_right()
void backtrack( struct point p ) { struct point stacktop; struct point tmp; struct point branch_point; // 1. struct point stacktop = get the top item from stack stacktop = get_top(); printf( "top is (%d, %d) \n", stacktop.row, stacktop.col ); // 2. get stacktop 's father point = branch_point branch_point = pre[stacktop.row][stacktop.col]; printf( "father is (%d, %d) \n", branch_point.row, branch_point.col); // 3. from p to branch_point tmp = p; while( !(tmp.row==branch_point.row && tmp.col==branch_point.col) ) { struct point save; maze[tmp.row][tmp.col] = 0; save = tmp; tmp = pre[tmp.row][tmp.col]; pre[save.row][save.col].row = 0; pre[save.row][save.col].col = 0; print_maze(); print_pre(); //getchar(); } }
/** * Returns the position within the parent window. */ gcc_pure const RECT get_position() const { RECT rc; #ifdef ENABLE_SDL rc.left = get_left(); rc.top = get_top(); rc.right = get_width(); rc.bottom = get_height(); #else rc = get_screen_position(); HWND parent = ::GetParent(hWnd); if (parent != NULL) { POINT pt; pt.x = rc.left; pt.y = rc.top; ::ScreenToClient(parent, &pt); rc.left = pt.x; rc.top = pt.y; pt.x = rc.right; pt.y = rc.bottom; ::ScreenToClient(parent, &pt); rc.right = pt.x; rc.bottom = pt.y; } #endif return rc; }
G_GNUC_NORETURN WS_MSVC_NORETURN static void do_throw(except_t *except) { struct except_stacknode *top; assert (except->except_id.except_group != 0 && except->except_id.except_code != 0); for (top = get_top(); top != 0; top = top->except_down) { if (top->except_type == XCEPT_CLEANUP) { top->except_info.except_cleanup->except_func(top->except_info.except_cleanup->except_context); } else { struct except_catch *catcher = top->except_info.except_catcher; const except_id_t *pi = catcher->except_id; size_t i; assert (top->except_type == XCEPT_CATCHER); except_free(catcher->except_obj.except_dyndata); for (i = 0; i < catcher->except_size; pi++, i++) { if (match(&except->except_id, pi)) { catcher->except_obj = *except; set_top(top); longjmp(catcher->except_jmp, 1); } } } } set_top(top); get_catcher()(except); /* unhandled exception */ abort(); }
void stackvars_note_exit(const char *fun_name) { stack_node **top = get_top(); assert(*top != NULL && strcmp(fun_name, (*top)->fun_name) == 0); stack_node *old_node = *top; *top = (*top)->next; free_stack_node(old_node); }
TITANIUM_PROPERTY_GETTER(Animation, top) { auto top = get_top(); if (top) { get_context().CreateNumber(*top); } return get_context().CreateUndefined(); }
void except_rethrow(except_t *except) { struct except_stacknode *top = get_top(); assert (top != 0); assert (top->type == XCEPT_CATCHER); assert (&top->info.catcher->obj == except); set_top(top->down); do_throw(except); }
G_GNUC_NORETURN WS_MSVC_NORETURN void except_rethrow(except_t *except) { struct except_stacknode *top = get_top(); assert (top != 0); assert (top->except_type == XCEPT_CATCHER); assert (&top->except_info.except_catcher->except_obj == except); set_top(top->except_down); do_throw(except); }
void poststat(int mytype) { #ifdef REDIS //KBS 统计十大失败时,不更新十大数据 if (get_top(mytype) == 0) return; #else get_top(mytype); #endif /* REDIS */ writestat(mytype); if (mytype==0) backup_top(); gen_hot_subjects_xml(mytype); if (mytype==0) gen_secs_hot_subjects_xml(mytype); if (mytype==0) log_top(); }
void WnCourt::CreateWord(const char *text) { wnobj *top = get_top(); if (top) { PangoLayout *layout = gtk_widget_create_pango_layout(drawing_area, text); newobj = _court->create_word(layout); _court->create_spring(newobj, top, init_spring_length); newobj->getP().getP() = get_next_pos(get_top()->getP().getP()); } else { PangoLayout *layout = gtk_widget_create_pango_layout(drawing_area, ""); gchar *str = g_markup_printf_escaped("<big><b>%s</b></big>", text); pango_layout_set_markup(layout, str, -1); g_free(str); newobj = _court->create_word(layout); newobj->getP().getP() = get_center_pos(); _court->set_center(newobj); } }
int Rectangle::hit_test (float x, float y) { if ((x > left) && (x<get_right())) { if ((y > get_bottom()) && (y<get_top())) return 1; } return 0; }
BOOL reach_end(SqStack *s){ Point p; if (!stack_empty(s)) { get_top(s, &p); if (p.coordi.x==end.x && p.coordi.y==end.y) { return TRUE; } } return FALSE; }
Item pop() { if (this->get_top() != this->get_base()) { StackElement<Item>* last_top = get_top(); Item ret_item = peek(); this->set_top(top->get_next()); delete last_top; return ret_item; } else return (Item) nullptr; }
void stackvars_note_entry(const char *fun_name) { stack_node **top = get_top(); stack_node *new_node = malloc(sizeof(stack_node)); new_node->fun_name = fun_name; new_node->formals = NULL; new_node->locals = NULL; new_node->next = *top; *top = new_node; }
void stackvars_move_to_heap(void) { stack_node **top = get_top(); stack_node *cur = *top; while (cur) { copy_vars_to_heap(cur->formals); copy_vars_to_heap(cur->locals); cur = cur->next; } }
void WnCourt::CreateNode(const char *text, const char *type) { newobj = _court->create_ball(text, type); wnobj *top = get_top(); if (top) { _court->create_spring(newobj, top, init_spring_length, 0.4f); newobj->getP().getP() = get_next_pos(top->getP().getP()); } else { newobj->getP().getP() = get_center_pos(); } }
/***************************************************************************** * Function to create a pthread function on the PPU (start the SPE thread) *****************************************************************************/ void * compute_thread_function(void *arg) { thread_args_t *args = (thread_args_t *)arg; thread_manager_t *manager = args->manager; task_data_t *task; int fd = manager->pipe[args->id*2+1]; double running = 0.; double waiting = 0.; double overhead = 0.; struct timespec started; struct timespec stopped; while( 1 ) { // Get job from queue (timed) clock_gettime(CLOCK_REALTIME, &started); if( (task = (task_data_t *)get_top(&manager->queue)) != NULL ) break; clock_gettime(CLOCK_REALTIME, &stopped); waiting += get_nSeconds(&started, &stopped); // Make sure that the task job is valid if( task->job == NULL ) { fprintf(stderr, "Got NULL job, continuing.\n"); free( task ); continue; } // Run job (timed) clock_gettime(CLOCK_REALTIME, &task->scheduled); task->job(manager, task); clock_gettime(CLOCK_REALTIME, &task->completed); running += get_nSeconds(&task->scheduled, &task->completed); task->running_nsec = get_nSeconds(&task->scheduled, &task->completed); task->inflight_nsec = get_nSeconds(&task->enqueued, &task->completed); // Notify callback function of job completion clock_gettime(CLOCK_REALTIME, &task->scheduled); write(fd, &task, sizeof(void *)); clock_gettime(CLOCK_REALTIME, &task->completed); overhead += get_nSeconds(&task->scheduled, &task->completed); } // If we are here we got a NULL task, which is a graceful shutdown int nullPtr = (int)NULL; write(fd, &nullPtr, sizeof(void *)); // Send termination notice to the callback thread pthread_exit(NULL); // Terminate thread return NULL; }
void stackvars_summary(void) { stack_node **top = get_top(); stack_node *cur = *top; kitsune_log("Dumping the stack...\n"); while (cur) { kitsune_log("%s\n", cur->fun_name); var_summary("formals", cur->formals); var_summary("locals", cur->locals); cur = cur->next; } }
void bhvm::exec_calle (void) { std::string command = get_top(); exec_pop(); std::map<std::string, CountPtr< Signal<bhvm*> > >::iterator it = map_signal_external_commands.find(command); if (it == map_signal_external_commands.end() || it->second.isValid()==false) throw Alarm(MTK_HERE, "bhvm", MTK_SS("command not registered " << command), alPriorCritic); it->second->emit(this); }
void WndForm::ReinitialiseLayout() { if (main_window.get_width() < get_width() || main_window.get_height() < get_height()) { // close dialog, it's creator may want to create a new layout mModalResult = mrChangeLayout; } else { // reposition dialog to fit into TopWindow int left = get_left(); int top = get_top(); if (get_right() > (int) main_window.get_width()) left = main_window.get_width() - get_width(); if (get_bottom() > (int) main_window.get_height()) top = main_window.get_height() - get_height(); if (left != get_left() || top != get_top()) move(left, top); } }
void poststat(int mytype) { get_top(mytype); writestat(mytype); if(mytype==0) backup_top(); gen_hot_subjects_xml(mytype); if(mytype==0) gen_secs_hot_subjects_xml(mytype); if(mytype==0) log_top(); }
/** * \brief Check if a given item on bridge must be erase. * \param it Iterator on item to consider. * \param previous_pos Position of previous item. * \param next_pos Position of next item. */ bool bear::bridge::check_erase_item (items_list_iterator it, const universe::position_type& previous_pos, const universe::position_type& next_pos) const { return check_item ( it->get_reference_item()->get_center_of_mass(), previous_pos, next_pos, 0 ) || ( it->get_item().get() == NULL ) || ( it->get_item()->get_bottom() > get_top() ) || ( it->get_item()->get_horizontal_middle() < get_left() )|| ( it->get_item()->get_horizontal_middle() > get_right() ); } // bridge::check_erase_item()