void CScriptEngine::process_file_if_exists (LPCSTR file_name, bool warn_if_not_exist) { u32 string_length = xr_strlen(file_name); if (!warn_if_not_exist && no_file_exists(file_name,string_length)) return; string256 S,S1; if (m_reload_modules || (*file_name && !namespace_loaded(file_name))) { FS.update_path (S,"$game_scripts$",strconcat(S1,file_name,".script")); if (!warn_if_not_exist && !FS.exist(S)) { #ifdef DEBUG # ifndef XRSE_FACTORY_EXPORTS if (psAI_Flags.test(aiNilObjectAccess)) # endif { print_stack (); Msg ("* trying to access variable %s, which doesn't exist, or to load script %s, which doesn't exist too",file_name,S1); m_stack_is_ready = true; } #endif add_no_file (file_name,string_length); return; } #ifndef MASTER_GOLD Msg ("* loading script %s",S1); #endif // MASTER_GOLD m_reload_modules = false; load_file_into_namespace(S,*file_name ? file_name : "_G"); } }
void do_it(FILE *p,int *btm,int cap) { int *top; int count = 0; top = NULL; int mode = read(p); while(mode != 0) { if(mode == 1) { if(count >= cap) printf("STACK OWERFOLW\n"); else { int ins = read(p); top = push(top,ins,btm); count++; } } if(mode == 2) { top = pop(top,btm); count--; } if(mode == 3) peek(top); if(mode == 4) print_stack(top,btm); mode = read(p); } }
int main() { head=NULL; int data,choice=1; while(choice) { printf("\t\tMENU\n1:Push\n2:Pop\n3:Print\n0:Exit\f"); scanf("%d",&choice); switch(choice) { case 1: printf("Enter the number : "); scanf("%d",&data); push(data); break; case 2: pop(); break; case 3: print_stack(head); break; case 0: return 0; default: printf("Wrong Input . Please enter again.....\n"); break; } } return 0; }
static void print_stacks(void) { struct key_t key = {}, next_key; __u64 value; __u32 stackid = 0, next_id; int fd = map_fd[0], stack_map = map_fd[1]; sys_read_seen = sys_write_seen = false; while (bpf_map_get_next_key(fd, &key, &next_key) == 0) { bpf_map_lookup_elem(fd, &next_key, &value); print_stack(&next_key, value); bpf_map_delete_elem(fd, &next_key); key = next_key; } if (!sys_read_seen || !sys_write_seen) { printf("BUG kernel stack doesn't contain sys_read() and sys_write()\n"); int_exit(0); } /* clear stack map */ while (bpf_map_get_next_key(stack_map, &stackid, &next_id) == 0) { bpf_map_delete_elem(stack_map, &next_id); stackid = next_id; } }
int popd(){ print_stack(root); printf("\n"); char * new_dir = stack_pop(root); root = root->next; return cd(new_dir); }
void walk(int point, struct stack_t* stk, struct ALGraph* _alg) { int idx = -1; struct point_t* next_point = NULL; struct ALGraph* alg = NULL; alg = (struct ALGraph*)malloc(sizeof(struct ALGraph)); init_ALGraph(alg); cpy_ALGraph(alg, _alg); //fprintf(stdout, "\n--------------------\n"); //print_ALGraph(alg); stack_push(stk, point); //print_stack(stk); /*是否全部走完*/ if (if_walk_through(alg)) { print_stack(stk); return; } idx = find_point(alg, point); if (-1 == idx) { fprintf(stderr, "find_point THIS CAN NOT HAPPEN!\n"); exit(-1); } next_point = alg->point_array[idx].next; while (next_point != NULL) { idx = find_edge(alg, point, next_point->val); if (-1 == idx) { fprintf(stderr, "find_edge THIS CAN NOT HAPPEN!\n"); exit(-1); } if (!alg->edge_array[idx].walk) { alg->edge_array[idx].walk = 1; walk(next_point->val, stk, alg); stack_pop(stk); alg->edge_array[idx].walk = 0; } next_point = next_point->next; } return; }
void change_times(Time& t1, Time t2) { label_stack((uintptr_t *)&t1, "t1"); label_stack((uintptr_t *)&t2, "t2"); std::cout << "Before calling - IN change_times" << std::endl; print_stack(); t1.setHour(15); t1.setMinute(20); t1.setSecond(21); t2.setMinute(50); std::cout << "after calling - IN change_times " << std::endl; print_stack(); }
void Logger::fatal(const char* fmt, ...){ print_stack(); va_list vl; va_start(vl, fmt); logv(Logger::FATAL, fmt, vl); va_end(vl); abort(); }
void print_stack(struct NODE *temp) { if(temp==NULL) return; print_stack(temp->next); printf("%d-->",temp->data); return; }
void print_trace(state_t *st) { fprintf(stderr, "DEBUG:\nStack:\n"); print_stack(st); fprintf(stderr, "Global vars:\n"); print_vars(st->vars, 1); fprintf(stderr, "Local vars:\n"); print_vars(st->frame->vars, 0); fprintf(stderr, "\n"); }
static duk_ret_t test_1(duk_context *ctx) { printf("test_1\n"); prep(ctx); /* extend with undefined */ duk_set_top(ctx, 5); print_stack(ctx); /* chop, using a negative top value */ duk_set_top(ctx, -3); /* = duk_set_top(ctx, 2) */ print_stack(ctx); /* to empty */ duk_set_top(ctx, 0); print_stack(ctx); return 0; }
void print_stack(StackNode * node){ if(node != NULL){ printf("%s",node->item); if(node->next != NULL){ printf(" "); print_stack(node->next); } } }
void print_stack(){//print the stack out if(isEmptyStack()){ return;//get out if we are at the end }else{ int temp = pop();//temp to hold value printf("%d\n", temp);//display val print_stack();//recur push(temp);//add value back when we get returned here } }
void sa(t_stack *stack, int x) { int tmp; tmp = stack->a_end->data; stack->a_end->data = stack->a_end->prev->data; stack->a_end->prev->data = tmp; ++stack->n_moves; if (x && !stack->no_command) s_list_push(&stack->moves, s_list_new(ft_strdup("sa"))); if (stack->status && x) { print_stack(&stack->a_begin, stack->number_in_a, 'a', stack->color); print_stack(&stack->b_begin, stack->number_in_b, 'b', stack->color); if (!stack->no_command) print_command(stack); write(1, "\n", 1); } }
static void terminate_handler() { fprintf(stderr, "Caught unhandled exception\n"); print_stack(); #ifdef __GNUG__ __gnu_cxx::__verbose_terminate_handler(); #else std::abort(); #endif }
void printm(struct _6510_cpu* cpu, char memory[][9]){ int adr = 12 ; printf("\nmem[%02x'%02x] = \t %02x\n", conv_bitstr2int(cpu->pch,0,7), conv_bitstr2int(cpu->pcl,0,7), conv_bitstr2int(memory[adr],0,7)); print_stack(cpu, memory); printf("abrl: \t\t %02x\n", conv_bitstr2int(cpu->abrl,0,7)); printf("abrh: \t\t %02x\n", conv_bitstr2int(cpu->abrh,0,7)); printf("dbr: \t\t %02x\n", conv_bitstr2int(cpu->dbr,0,7)); printf("***********************************\n\n"); }
Stack* initialValue(Stack** s, int num) { int i; for( i = 10 ; i > 0 ; i-- ) { //int tmp = rand() % 100; push(s , i); } print_stack(*s); }
static void print_stacks(int fd) { struct key_t key = {}, next_key; __u64 value; while (bpf_map_get_next_key(fd, &key, &next_key) == 0) { bpf_map_lookup_elem(fd, &next_key, &value); print_stack(&next_key, value); key = next_key; } }
void _pabort(const char *s) { if (s) { //perror(orig_buf); psyslog("%s :STACK:", s); } print_stack(); #ifdef MINERGATE exit_nicely(0, "apAbort"); #else exit(0); #endif }
int main(){ Stack *s; int v =5; int x; float t = 6; s = init(); push(v,s); push(v,s); push(v,s); push(v,s); push(v,s); print_stack(s); printf("Pop operation: %d\n", pop(s)); print_stack(s); printf("Pop operation: %d\n", pop(s)); print_stack(s); printf("Pop operation: %d\n", pop(s)); print_stack(s); printf("Pop operation: %d\n", pop(s)); print_stack(s); printf("Pop operation: %d\n", pop(s)); print_stack(s); printf("Pop operation: %d\n", pop(s)); // print_stack(s); }
int main() { int i; init_stack(&s); for (i=1; i<= 10; ++i) push(&s ,i); print_stack(&s); return 0; }
void Program::push_call(PlainId fn_name, term_v ¶ms) { if (tracing_enabled) program_profiler.push_call(fn_name); if (stack.size() > 200) { cout << "Stack overflow!\n"; print_stack(); halt; } stack.push_back(StackEntry(fn_name, params)); }
void main(){ stack s; make_stack(&s); push(1, &s); push(2, &s); push(3, &s); push(4, &s); push(5, &s); push(6, &s); push(7, &s); push(8, &s); push(9, &s); push(10, &s); //print_stack(&s); push(11, &s); //print_stack(&s); pop(&s); print_stack(&s); free_stack(&s); print_stack(&s); }
int test_aba() { #if NON_BLOCKING == 1 || NON_BLOCKING == 2 // Write here a test for the ABA problem pthread_attr_t attr; pthread_t thread[2]; stack_measure_arg_t args[2]; stack_element_t* element; int i, success, aba_detected = 0;; while (stack->head != NULL){ free(stack_pop(stack)); } element = malloc(sizeof(stack_element_t)); element->value = 'C'; stack_push(stack, element); element = malloc(sizeof(stack_element_t)); element->value = 'B'; stack_push(stack, element); element = malloc(sizeof(stack_element_t)); element->value = 'A'; stack_push(stack, element); print_stack("Init"); pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); pthread_barrier_init(&aba_barrier, NULL, 3); pthread_create(&thread[0], &attr, &aba_1, (void*) &args[0]); pthread_create(&thread[1], &attr, &aba_2, (void*) &args[1]); pthread_barrier_wait(&aba_barrier); for (i = 0; i < 2; i++) { pthread_join(thread[i], NULL); } success = aba_detected; return success; #else // No ABA is possible with lock-based synchronization. Let the test succeed only return 1; #endif }
void free(void *ptr) { if(!real_free) { if(!real_free) return; } real_free(ptr); if(memlog) { LOCK; fprintf(memlog, "free 0x%08x ", ptr); print_stack(); fprintf(memlog, "\n"); UNLOCK; } }
int main(int argc, char **argv) { struct node *root = NULL; int i; int code = -1; const char *filelist[argc]; if(argc == 1) { printf("No files to (F)lex!\n"); return 0; } /* Put file names in list */ argc--; argv++; for (i = 0; i < argc; i++) { filelist[i] = argv[i]; } /* Push onto flex's convenient buffer */ for (i = 0; i < argc; i++) { // yyin = fopen(filelist[i],"r"); yyin = fopen(argv[i],"r"); if (yyin == NULL) { printf("%s is not a file!\n",filelist[i]); return 0; } /* Push onto filestack as defined in token.c */ push_node(&filestack, filelist[i]); yypush_buffer_state(yy_create_buffer(yyin, YY_BUF_SIZE)); } printf("FILES TO BE PARSED:\n"); print_stack(&filestack); int parse_code = 0; while(!feof(yyin)) { parse_code = yyparse(); } printf("Result: %d\n", parse_code); // printf("%s\n",yylval.tptr->name); treeprint(t_unit, 0); return 0; }
int main(){ STACK *s = create_stack(); int i; printf("PUSH TIME\n"); for(i = 0; i < 10; i++){ print_stack(s); push(s, i); } printf("POP TIME\n"); while( !empty(s) ){ print_stack(s); pop(s); } print_stack(s); destroy_stack(&s); print_stack(s); return 0; }
int main(void) { int x; Stack myStack = NULL; for(x = 0; x < 4; x++) { StackPush(&myStack, x); } print_stack(&myStack); while(myStack != NULL) { printf("data: %d\n", StackPop(&myStack)); } return 0; }
int main(int argc, char *argv[]){ ////////Lista struct List *list; int i; list = init_list(); for(i=1; i<=10; i++){ add(list,i); } print_list(list); destroy_list(list); ////////Cola struct COLA *Cola; int j; Cola = init_cola(); for(j=1; j<=10; j++){ add(Cola,j); } print_cola(Cola); destroy_cola(Cola); ////////Pila struct Stack *stack; int k; stack = init_stack(); for(k=1; k<=10; k++){ add(stack,k); } print_stack(stack); destroy_stack(stack); return 1; }
int main(int argc, const char *argv[]) { mstack_t *sp; int i; data_t buf; sp = creat_stack(6); for(i = 0 ; i < 10;i ++){ push_stack(sp,&i); } print_stack(sp); pop_stack(sp,&buf); printf("pop : %d\n",buf); pop_stack(sp,&buf); printf("pop : %d\n",buf); pop_stack(sp,&buf); printf("pop : %d\n",buf); print_stack(sp); return 0; }