View difference between Paste ID: 7mdNGTfw and QiLnGh1c
SHOW: | | - or go back to the newest paste.
1
void llmrg(struct llist *dest, struct llist *src1, struct llist *src2) {
2
	struct llnode
3
		*node1 = src1->front,
4-
		*node2 = src2->front;
4+
		*node2 = src2->front,
5-
	struct llnode current==NULL;
5+
		*current==NULL;
6
7
	while( (node1!=NULL) || (node2!=NULL) ) {
8
		struct llnode *next = NULL;
9
10
		if( (node1!=NULL) && ( node1->item <= node2.item ) {
11
			next=node1;
12
			node1=node1->next;
13
			
14
		}else{
15
			next=node2;
16
			node2=node2->next;
17
			next->next = NULL;
18
		}
19
20
		if(current!=NULL) {
21
			current->next = next;
22
		}
23
24
		current = next;
25
		current->next = NULL;
26
		
27
		if(dest->front == NULL) {
28
			dest->front = current;
29
		}
30
	}
31
}