//Launch method, instead of having all this main basically... void create_list() { printf("Assembling list nodes...\n"); //We're assembling all this, correctly malloc()ing, //instead of creating inside this function with struct //vars, which would only be scoped to this function. // //First, setup the root. If anything else in this app needs this, //we'll pass it as a param, instead of using a global var. struct LinkNode *root_node = malloc(sizeof(struct LinkNode)); root_node->node_val = 9; root_node->next_node = NULL; add_item_to_list(12, root_node); //Add an item and store a pointer to it for future deletion test struct LinkNode *node_to_delete = add_item_to_list(10, root_node); add_item_to_list(22, root_node); add_item_to_list(37, root_node); printf("\nIterate through nodes and print values...\n\n"); print_list_values(root_node); printf("\nAdding value 55 to end of list...\n"); add_item_to_list(55, root_node); printf("\nNow reading all values again...\n\n"); print_list_values(root_node); printf("\nRemoving item with value 10 from the list\n"); //Do removal... remove_item_from_list(node_to_delete, root_node); printf("\nNow reading all values again...\n\n"); print_list_values(root_node); printf("\nAdding 2 new values: 66 and 77...\n"); add_item_to_list(66, root_node); add_item_to_list(77, root_node); printf("\nGet count of nodes...\n"); int node_count = count_list_nodes(root_node); printf("\nNode count: %d\n",node_count); printf("\nNow reading all values again...\n\n"); print_list_values(root_node); printf("\nFree()ing list memory...\n\n"); free_list_memory(&root_node); printf("\nNow reading all values again...\n\n"); print_list_values(root_node); }
static int fbconfig_release(struct inode *inode, struct file *file) { if(record_head ==NULL) return 0 ; else { record_list_initialed = 0; #if 1//FBCONFIG_DEBUG print_from_head_to_tail(); fbconfig_backup_lcm_setting(); print_from_head_to_tail_backup(); #endif #if 1 if(lcm_params->dsi.mode != CMD_MODE) { printk("sxk=>01will exec cmd!! in fbconfig_release()\n"); if (down_interruptible(&sem_early_suspend)) { printk("sxk=>can't get semaphore in execute_cmd()\n"); return 0; } fbconfig_dsi_vdo_prepare();//video mode printk("sxk=>FINISH!!\n"); up(&sem_early_suspend); } else{//cmd mode if (down_interruptible(&sem_early_suspend)) { printk("sxk=>can't get semaphore in execute_cmd()\n"); return 0; } fb_config_execute_cmd(); up(&sem_early_suspend); } #endif /*free the memory .....*/ printk("sxk=>will free the memory \n"); free_list_memory(); return 0; } }