forked from troydhanson/uthash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest64.c
67 lines (60 loc) · 1.23 KB
/
test64.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <stdio.h>
#include "utlist.h"
typedef struct el {
int id;
struct el *next, *prev;
} el;
int main()
{
int i;
el els[10], *e;
el *headA = NULL;
el *headB = NULL;
for(i=0; i<10; i++) {
els[i].id=(int)'a'+i;
}
/* test DL macros */
printf("DL macros\n");
DL_APPEND(headA,&els[0]);
DL_APPEND(headA,&els[1]);
DL_APPEND(headA,&els[2]);
DL_FOREACH(headA,e) {
printf("%c ", e->id);
}
printf("\n");
DL_APPEND(headB,&els[3]);
DL_APPEND(headB,&els[4]);
DL_APPEND(headB,&els[5]);
DL_FOREACH(headB,e) {
printf("%c ", e->id);
}
printf("\n");
DL_CONCAT(headA,headB);
DL_FOREACH(headA,e) {
printf("%c ", e->id);
}
printf("\n");
/* other variations */
headA = NULL;
DL_CONCAT(headA,headB);
DL_FOREACH(headA,e) {
printf("%c ", e->id);
}
printf("\n");
headB = NULL;
DL_CONCAT(headA,headB);
DL_FOREACH(headA,e) {
printf("%c ", e->id);
}
printf("\n");
headA=NULL;
headB=NULL;
DL_APPEND(headA,&els[0]);
DL_APPEND(headB,&els[1]);
DL_CONCAT(headA,headB);
DL_FOREACH(headA,e) {
printf("%c ", e->id);
}
printf("\n");
return 0;
}