static list_element * new_list( void ) { list_element *list; if ( create_list( &list ) == false ) { assert( 0 ); } return list; }
void config_defaults(struct sway_config *config) { config->symbols = create_list(); config->modes = create_list(); config->cmd_queue = create_list(); config->workspace_outputs = create_list(); config->current_mode = malloc(sizeof(struct sway_mode)); config->current_mode->name = NULL; config->current_mode->bindings = create_list(); list_add(config->modes, config->current_mode); // Flags config->focus_follows_mouse = true; config->mouse_warping = true; config->reloading = false; config->active = false; config->failed = false; config->gaps_inner = 0; config->gaps_outer = 0; }
int main(int argv, char *argc[]) { int node; printf("No of nodes to create\n"); scanf("%d", &node); create_list(node); assign_data(); print_list(); }
void CChoosebook::show() { init(); SetBackPixmap(g_pReciteWord->fixed,Skin->choosebook.choosebook.p[0]); book_index_label = gtk_label_new(NULL); gtk_fixed_put (GTK_FIXED (g_pReciteWord->fixed), book_index_label, Skin->choosebook.book_index_label.x[0], Skin->choosebook.book_index_label.y[0]); gtk_widget_show (book_index_label); book_count_label = gtk_label_new(NULL); gtk_fixed_put (GTK_FIXED (g_pReciteWord->fixed), book_count_label, Skin->choosebook.book_count_label.x[0], Skin->choosebook.book_count_label.y[0]); gtk_widget_show (book_count_label); word_count_label = gtk_label_new(NULL); gtk_fixed_put (GTK_FIXED (g_pReciteWord->fixed), word_count_label, Skin->choosebook.word_count_label.x[0], Skin->choosebook.word_count_label.y[0]); gtk_widget_show (word_count_label); book_filename_label = gtk_label_new(NULL); gtk_widget_set_size_request(book_filename_label, Skin->reciteword.width - Skin->choosebook.book_filename_label.x[0], -1); gtk_label_set_line_wrap(GTK_LABEL(book_filename_label), true); gtk_fixed_put (GTK_FIXED (g_pReciteWord->fixed), book_filename_label, Skin->choosebook.book_filename_label.x[0], Skin->choosebook.book_filename_label.y[0]); gtk_widget_show (book_filename_label); list = create_list(); gtk_fixed_put (GTK_FIXED (g_pReciteWord->fixed), list, Skin->choosebook.book_list.x[0], Skin->choosebook.book_list.y[0]); gtk_widget_show(list); tree = create_tree(); gtk_fixed_put (GTK_FIXED (g_pReciteWord->fixed), tree, Skin->choosebook.book_tree.x[0], Skin->choosebook.book_tree.y[0]); gtk_widget_show(tree); if (g_pReciteWord->now_book && g_pReciteWord->now_book->bookfilename) { gchar *a,book_dir[256]; strcpy(book_dir,g_pReciteWord->now_book->bookfilename); a=strrchr(book_dir,G_DIR_SEPARATOR); if (a) // book_dir is not aways separate by G_DIR_SEPARATOR. *a='\0'; GtkTreeModel *model; model = gtk_tree_view_get_model(GTK_TREE_VIEW(tree_view)); gtk_tree_model_foreach (model, select_dir_func, &book_dir); model = gtk_tree_view_get_model(GTK_TREE_VIEW(list_view)); gtk_tree_model_foreach (model, select_book_func, g_pReciteWord->now_book->bookfilename); } return_button.create(g_pReciteWord->fixed,Skin->choosebook.return_button.x[0],Skin->choosebook.return_button.y[0],Skin->choosebook.return_button.p[0],Skin->choosebook.return_button.p[1],Skin->choosebook.return_button.p[2],(GdkPixmap*) NULL,on_choosebook_return_clicked); ok_button.create(g_pReciteWord->fixed,Skin->choosebook.ok_button.x[0],Skin->choosebook.ok_button.y[0],Skin->choosebook.ok_button.p[0],Skin->choosebook.ok_button.p[1],Skin->choosebook.ok_button.p[2],(GdkPixmap*) NULL,on_choosebook_ok_clicked); }
int main() { struct node *list = create_list(1024); apply(list, &print); free_list(list); return 0; }
priv_ptr PrivPtr::create_ptr(int level, int type) { priv_ptr ptr = (priv_ptr)malloc(sizeof(struct priv_ptr_)); ptr->list = create_list(); ptr->size = 0; ptr->level = level; ptr->type = type; return ptr; }
void testcases() { struct node *res,*output; char *ip,*op; int i,check; for(i=0;i<9;i++) { res=output=NULL; ip=op=NULL; ip=malloc_str(testDB[i].input); ip=valid_str(ip); //if(ip==NULL) //printf("hai\n"); if(ip!=NULL) { ip=rem_space(ip); res=create_list(ip); //display(res); res=swap_adj_nodes(res); } else { res=NULL; } op=malloc_str(testDB[i].output); output=create_list(op); //if(res==NULL) check=list_cmp(res,output); display(res); display(output); if(check==0) printf("passed\n"); else printf("failed\n"); free(op); free(ip); free(res); free(output); } }
static void ipc_update_workspaces(struct bar *bar) { int i; for (i = 0; i < bar->outputs->length; ++i) { struct output *output = bar->outputs->items[i]; if (output->workspaces) { free_workspaces(output->workspaces); } output->workspaces = create_list(); } uint32_t len = 0; char *res = ipc_single_command(bar->ipc_socketfd, IPC_GET_WORKSPACES, NULL, &len); json_object *results = json_tokener_parse(res); if (!results) { free(res); return; } int length = json_object_array_length(results); json_object *ws_json; json_object *num, *name, *visible, *focused, *out, *urgent; for (i = 0; i < length; ++i) { ws_json = json_object_array_get_idx(results, i); json_object_object_get_ex(ws_json, "num", &num); json_object_object_get_ex(ws_json, "name", &name); json_object_object_get_ex(ws_json, "visible", &visible); json_object_object_get_ex(ws_json, "focused", &focused); json_object_object_get_ex(ws_json, "output", &out); json_object_object_get_ex(ws_json, "urgent", &urgent); int j; for (j = 0; j < bar->outputs->length; ++j) { struct output *output = bar->outputs->items[j]; if (strcmp(json_object_get_string(out), output->name) == 0) { struct workspace *ws = malloc(sizeof(struct workspace)); ws->num = json_object_get_int(num); ws->name = strdup(json_object_get_string(name)); ws->visible = json_object_get_boolean(visible); ws->focused = json_object_get_boolean(focused); if (ws->focused) { if (bar->focused_output) { bar->focused_output->focused = false; } bar->focused_output = output; output->focused = true; } ws->urgent = json_object_get_boolean(urgent); list_add(output->workspaces, ws); } } } json_object_put(results); free(res); }
int main() { struct list *head=create_list(0,NULL); struct list *temp=head; int n=10; for(int i=1;i<=n;i++) { temp->right=create_list(i,temp); temp=temp->right; } display(head); head=to_bst(&head,n+1); inorder(head); }
void ship_select::OnFilterShips() { int i; UpdateData(TRUE); create_list(); for (i = 0; i < Num_iffs; i++) GetDlgItem(IDC_FILTER_SHIPS_IFF[i])->EnableWindow(m_filter_ships); }
static swayc_t *new_swayc(enum swayc_types type) { swayc_t *c = calloc(1, sizeof(swayc_t)); c->handle = -1; c->layout = L_NONE; c->type = type; if (type != C_VIEW) { c->children = create_list(); } return c; }
main() { struct node *start=NULL; start=create_list(start); display(start); MoveLarge(start); display(start); MoveSmall(start); display(start); }/*End of main()*/
/*================================= * check_and_fix_records -- *================================*/ static void check_and_fix_records (void) { tofix = create_list(); todo.pass = 1; check_nodes(); todo.pass = 2; fix_nodes(); destroy_empty_list(tofix); }
void test(int test[], int n) { struct ListNode *list; create_list(test, n, &list); print_list(list); list = swapPairs(list); //list = swapPairs_by_ulyx(list); print_list(list); free_list(&list); printf("\n"); }
void add_breakpoint(uint32_t breakpoint_pc) { static uint32_t *new_element; if (story_has_been_loaded == false) { if (pcs == NULL) pcs = create_list(); new_element = malloc(sizeof(uint32_t)); *new_element = breakpoint_pc; add_list_element(pcs, new_element); } else { if (breakpoints == NULL) breakpoints = create_list(); add_list_element(breakpoints, z_mem + breakpoint_pc); } }
void init_meter_table( void ) { assert( table == NULL ); table = xmalloc( sizeof( meter_table ) ); memset( table, 0, sizeof( meter_table ) ); create_list( &table->entries ); table->initialized = true; }
/** copy_list * * Create a new list structure, new nodes, and new copies of the data by using * the copy function. Its implementation for any test structure must copy * EVERYTHING! * * @param llist A pointer to the linked list to make a copy of * @param copy_func A function pointer to a function that makes a copy of the * data that's being used in this linked list, allocating space for * every part of that data on the heap. This is some function you must * write yourself for testing, tailored specifically to whatever context * you're using the linked list for in your test. * @return The linked list created by copying the old one */ list* copy_list(list* llist, list_cpy copy_func) { list* copy_list_p = create_list(); node* current = llist->head; while (current != NULL) { push_back(copy_list_p, copy_func(current->data)); current = current->next; } return copy_list_p; }
static bool set_match_type( int argc, char *argv[], services *services ) { create_list( &services->arp_or_unicast ); create_list( &services->broadcast ); int i; char *service_name; for ( i = 1; i < argc; i++ ) { if ( ( service_name = match_type( ARP_OR_UNICAST, argv[ i ] ) ) != NULL ) { append_to_tail( &services->arp_or_unicast, service_name ); } else if ( ( service_name = match_type( BROADCAST, argv[ i ] ) ) != NULL ) { append_to_tail( &services->broadcast, service_name ); } else { return false; } } return true; }
void main(void){ int arr[]={1,2,3,4,5,6,7,8,9}; int len=sizeof(arr)/sizeof(arr[0]); Node *list=create_list(arr,len); char *str; str=to_str(list,len); printf("%s\n",str); int rst=dll_remove(list,list->fwd->fwd); str=to_str(list,len); printf("%s\n",str); }
int main(){ int arr[] = {1, 2, 3, 4, 5}; ListNode* l = create_list(arr, sizeof(arr)/sizeof(arr[0])); ListNode* r = swapPairs(l); while(r){ printf("%d ", r->val); r = r->next; } printf("\n"); return 0; }
void init_match_table( void ) { match_table_head.exact_table = create_hash( compare_match_entry, hash_match_entry ); create_list( &match_table_head.wildcard_table ); pthread_mutexattr_t attr; pthread_mutexattr_init( &attr ); pthread_mutexattr_settype( &attr, PTHREAD_MUTEX_RECURSIVE_NP ); match_table_head.mutex = xmalloc( sizeof( pthread_mutex_t ) ); pthread_mutex_init( match_table_head.mutex, &attr ); }
int main(){ int arr[] = {1, 2, 3, 4, 5}; ListNode* l = create_list(arr,sizeof(arr)/sizeof(arr[0])); l = reverseBetween(l,1,5); while(l){ printf("%d ", l->val); l = l->next; } printf("\n"); return 0; }
function_p create_function(void) { function_p n = (function_p)malloc(sizeof(function_s)); if(n == NULL) return NULL; n->desc = create_list(); if(n->desc == NULL) { free(n); return NULL; } n->params = create_list(); if(n->params == NULL) { destroy_list(n->desc); free(n); return NULL; } return n; }
static void init() { app_message_register_inbox_received(inbox); app_message_register_inbox_dropped(inbox_fail); app_message_register_outbox_sent(outbox_sucess); app_message_register_outbox_failed(outbox_failed); app_message_open(app_message_inbox_size_maximum(), app_message_outbox_size_maximum()); AccelLogging = create_list(); }
void boolean_preprocess(shellptr shellA, shellptr shellB, listptr vv_list,listptr vf_list) { listptr vee_list,ef_list; ; vee_list = create_list(); ef_list = create_list(); log_pure_vvs(shellA,shellB,vv_list); log_vertex_edges(shellA,shellB,vee_list); split_from_veelist(shellA,shellB,vee_list,vv_list); resolve_edge_faces(shellA,shellB,vf_list,ef_list); #ifdef debug topology_check(shellA); topology_check(shellB); malloc_check(); #endif }
int main(int argc, char** argv) { Node* head = create_list(); print_list(head); head = reverse_list(head); print_list(head); free_list(head); return 0; }
void init_group_table( void ) { assert( table == NULL ); table = xmalloc( sizeof( group_table ) ); memset( table, 0, sizeof( group_table ) ); create_list( &table->entries ); set_default_group_features( &table->features ); table->initialized = true; }
void get_character(IplImage * img) { img = cvLoadImage("img_plate_after_preprocess.bmp", -1); if (img == NULL) { fprintf(stderr, "Can not open file img_plate_after_preprocess.bmp"); exit(-1); } /*也是两个链表用来存放矩形的*/ List rects = create_list(); List rects_final = create_list(); if (img == NULL) { fprintf(stderr, "error in openning file.\n"); exit(-1); } CvMemStorage * storage = cvCreateMemStorage(0); CvSeq * contours = NULL; remove_border_ul(img); /*消除上下边界*/ IplImage * img_after_removed = cvLoadImage("img_after_border_removed.bmp", -1); if (img_after_removed == NULL) { fprintf(stderr, "Can not open file img_after_border_removed.bmp"); exit(-1); } make_border_black(img_after_removed); get_contour_rect(img_after_removed, rects, storage, contours); /*找到所有矩形*/ filter_rect_by_area(rects->next, rects_final, img_after_removed->width * img_after_removed->height); /*现在还要继续去除左右边界: 左右边界的特点是: 1.几乎全为白色点,注意1也是这样 2.面积不在1的范围之内,1的最大最小值定义在头文件中了 3.比例比1的大或小,比例也定义在头文件中了 */ rects_final = sort(rects_final); filter_rect_lr(rects_final, img_after_removed); draw_contour_rect(img_after_removed, rects_final->next); find_character(img_after_removed, rects_final); /*也没有什么好改进的地方了*/ }
int main() { // init tree int arr[] = {1, 2, 2, 4, 5}; // init list ListNode *head = create_list(arr, sizeof(arr) / sizeof(int)); removeElements(head, 2); print_list(head); return 1; }
t_param *init_param(int prog_count) { t_param *param; if ((param = malloc(sizeof(t_param))) == 0) return (NULL); param->nbr_cycle = 0; param->debug = 0; param->progs = create_list(NULL); param->prog_count = prog_count; return (param); }