Sequencer::~Sequencer() { for(int i = 0; i < NUM_MIDI_TRACKS; i++) { deletelist(&miditrack[i].track); deletelist(&miditrack[i].record); } }
int main(int argc, char **argv) { struct lnode *head = BuildOneTwoThree(); deletelist(&head); printf("Deleted. Traversing...\n"); traverse(head); printf("Traversal complete\n"); }
int Sequencer::importmidifile(char *filename){ if (midifile.loadfile(filename)<0) return(-1); int i; for (i=0;i<NUM_MIDI_TRACKS;i++){ deletelist(&miditrack[i].record); }; if (midifile.parsemidifile(this)<0) return(-1); //copy the "record" track to the main track for (i=0;i<NUM_MIDI_TRACKS;i++){ deletelist(&miditrack[i].track); miditrack[i].track=miditrack[i].record; deletelistreference(&miditrack[i].record); }; return(0); };
void deletelist(struct linked_node **head) { if(!*head);// if head = null do nothing= stop waiting. else{ deletelist(&((*head)->next));// delete the next head first free(*head);//free this head *head = NULL;// head points to nothing } }
/* A more difficult problem is to write a function InsertNth() which can insert a new node at any index within a list. Push() is similar, but can only insert a node at the head end of the list (index 0). The caller may specify any index in the range [0..length], and the new node should be inserted so as to be at that index. */ void insertnthtest() { struct node* head = NULL; insertnth(&head, 0, 13); //build 13 insertnth(&head, 1, 42); //build 13, 42 insertnth(&head, 1, 5); //build 13, 5, 42 deletelist(&head); }
/*根据关键字查找备选命令*/ int SearchCmdOption(const char *envpath, const char *text, char cmd_option[cmd_option_nummax][cmd_length], int *option_num) { dirlist=createlist(dirlist); char path[PATH_MAX+1]={'\0'}; strcpy(path,envpath); fillcmdop(path,text,cmd_option,option_num); deletelist(dirlist); return 1; }
int SearchFile(const char *envpath, const char *file, char *filepath) { dirlist=createlist(dirlist); char path[PATH_MAX+1]={'\0'}; strcpy(path,envpath); int finished=myftw(path, file,filepath); deletelist(dirlist); return finished; }
int deleteblock(u64_t blocknum) { getpath(blocknum); FILE *block; if ((block = fopen(path, "rb")) == NULL) { printf("block not exist!"); } else { fclose(block); remove(path); } deletelist(blocknum); return 0; }
int main(){ char buf[1024]; Num *op1,*op2,*res; printf("Operand #1 : "); scanf("%[0-9]*",buf); op1=createlist(buf); getchar(); printf("Operand #2 : "); scanf("%[0-9]*",buf); op2=createlist(buf); res=numadd(op1,op2); printlist(op1); printf("\n + \n"); printlist(op2); printf("\n = \n"); printlist(res); printf("\n"); deletelist(op1); deletelist(op2); deletelist(res); return 0; }
main() { struct node *head=NULL; int i; long rin; for(i=0;i<=10;i++) { push(&head,i); } play(head); deletelist(&head); printf("after the deletelist\n"); play(head); }
int main(int argc, char const *argv[]) { struct stu *s; int n, age; printf("Please input the length of seqlist:\n"); scanf("%d",&n); s = creatlist(n); display(s); printf("Please input the age:\n"); scanf("%d",&age); deletelist(s,age); display(s); return 0; }
int main() { addfront(1); display(); addfront(2); display(); addfront(3); display(); addfront(4); display(); addrear(5); display(); addrear(6); display(); addrear(7); display(); addrear(8); display(); addrear(9); display(); deletelist(); display(); deletelist(); display(); /* addafter(10, 5); display(); addafter(20,10); display(); addafter(20, 9); display(); addafter(21, 20); display(); addrear(22); display(); addbefore(30, 3); display(); addbefore(31, 4); display(); addbefore(32, 5); display(); addbefore(33, 299); display(); addnth(40, 10); display(); addnth(41, 0); display(); addnth(42, 1); display(); addnth(43, length()); display(); addnth(44, length()+1); display(); */ return 0; }
void flushwrites( int socket ) { if ( !mFlushDelay.poll() ) return; sviterator iter = ( mMapper.Begin() ), end = ( mMapper.End() ); while ( iter != end ) { packetlist *packets = ( iter.value() ); packets->head()->send( socket ); delete packets->pophead(); if ( !packets->count() ) { deletelist( packets ); iter.Delete(); // delete advances iter } else { ++iter; } } if ( mCompactDelay.poll() ) mMapper.Compact(); }
~udpqueue() { sviterator iter = ( mMapper.Begin() ), end = ( mMapper.End() ); for ( ; iter != end; ++iter ) deletelist( iter.value() ); }
/*----------------Test Driver---------------------*/ void main(){ struct node* mylist = buildonetwothree(); deletelist(&mylist); }
int main(int argc, char const *argv[]) { int num; int data,pos; bool flag = FALSE; DLinkList pnode; DLinkList list = createlist(0); while(flag == FALSE) { printf("Main Menu\n"); printf("1. Insert\n"); printf("2. Delete Node\n"); printf("3. Find\n"); printf("4. Length\n"); printf("5. Positive print\n"); printf("6. Negative print\n"); printf("7. Delete list\n"); printf("8. Insert data where are you hope\n"); scanf("%d",&num); switch(num) { case 1: printf("Input the data to Insert:\n"); scanf("%d",&data); list = create(list,data); printlist(list); printf("\n");break; case 2: printf("Input the data to Delete:\n"); scanf("%d",&data); deletenode(list,data); printlist(list); printf("\n");break; case 3: printf("Input the data to Find:\n"); scanf("%d",&data); pnode = findnode(list,data); if (NULL != pnode) { printf("find succeed! position is %d\n",pnode->data); printf("\n"); } else{ printf("Find failed\n"); printf("\n"); } break; case 4: printf("The list's length is %d\n",getlength(list)); printf("\n");break; case 5: printlist(list); //printf("\n"); break; case 6: reverprint(list); printf("\n");break; case 7: deletelist(list); printf("\n");break; case 8: printf("Input the data to Insert:\n"); scanf("%d,%d",&pos,&data); list = crdata(list,pos,data); printlist(list); printf("\n");break; case 0: deletelist(list); flag = TRUE; } } return 0; }
int main(int argc, char* argv[]) { int sockfd, clientfd,status,yes=1,fdmax,p,fd,j; unsigned int port; struct addrinfo hints; struct addrinfo *servinfo; struct sockaddr_in* clientinfo; // will point to the results fd_set master,read_fd; memset(&hints, 0, sizeof hints); // make sure the struct is empty FD_ZERO(&master); FD_ZERO(&read_fd); if (argc != 4) { printf("usage: ./server ip port clientcount\n"); return 1; } port =atoi(argv[2]); printf("IP Entered,%s\n",argv[1]); servinfo= (struct addrinfo*)calloc(1,sizeof(struct addrinfo)); InitAddress (argv[1], port, servinfo); MAX_COUNT = atoi(argv[3]); //Max number of clients // create userlist userlist = initlist(); // make a socket: if ((sockfd = socket(servinfo->ai_family, servinfo->ai_socktype,servinfo->ai_protocol)) == -1) { perror("server: socket"); exit(0); } // local addresses are reused if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &yes,sizeof(int)) == -1) { perror("setsockopt"); exit(1); } // binding to a port if (bind(sockfd, servinfo->ai_addr, servinfo->ai_addrlen) == -1) { close(sockfd); perror("server: bind"); } //listen if(listen(sockfd,MAX_COUNT)==-1){ close(sockfd); perror("server:listen"); } FD_SET(sockfd,&master); fdmax = sockfd; while(1){ read_fd = master; if( select(fdmax+1,&read_fd,NULL,NULL,NULL) == -1){ perror("server:select"); exit(0); } for(p=0;p<=fdmax;p++) { if(FD_ISSET(p,&read_fd)){ if(p==sockfd){ // New connection int clientfd = handle_new_cnt(p,master,&fdmax); if(clientfd) FD_SET(clientfd,&master); } else {// received some msg from old connection if(!handle_old_cnt(p,master,fdmax,sockfd)) { char usrname[17]; if(searchlist(p,userlist,usrname)) userlist=deletelist(p,userlist);; //closing the user incase he has quit printf("\nNumber of valid users\t:%d\n",list_size(userlist)); close(p); FD_CLR(p,&master); } } } //data handling done }//data for particular p over }// infinite loop close(sockfd); //printsockaddr((struct sockaddr_in*)servinfo->ai_addr); freeaddrinfo(servinfo); // free the linked-list }