diff options
author | David Walter Seikel | 2013-01-13 17:29:19 +1000 |
---|---|---|
committer | David Walter Seikel | 2013-01-13 17:29:19 +1000 |
commit | 07274513e984f0b5544586c74508ccd16e7dcafa (patch) | |
tree | b32ff2a9136fbc1a4a6a0ed1e4d79cde0f5f16d9 /libraries/eina/src/examples/eina_inlist_01.c | |
parent | Added Irrlicht 1.8, but without all the Windows binaries. (diff) | |
download | SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.zip SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.gz SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.bz2 SledjHamr-07274513e984f0b5544586c74508ccd16e7dcafa.tar.xz |
Remove EFL, since it's been released now.
Diffstat (limited to '')
-rw-r--r-- | libraries/eina/src/examples/eina_inlist_01.c | 97 |
1 files changed, 0 insertions, 97 deletions
diff --git a/libraries/eina/src/examples/eina_inlist_01.c b/libraries/eina/src/examples/eina_inlist_01.c deleted file mode 100644 index 6c6c794..0000000 --- a/libraries/eina/src/examples/eina_inlist_01.c +++ /dev/null | |||
@@ -1,97 +0,0 @@ | |||
1 | // Compile with: | ||
2 | // gcc -g eina_inlist_01.c -o eina_inlist_01 `pkg-config --cflags --libs eina` | ||
3 | |||
4 | #include <Eina.h> | ||
5 | #include <stdio.h> | ||
6 | |||
7 | struct my_struct { | ||
8 | EINA_INLIST; | ||
9 | int a, b; | ||
10 | }; | ||
11 | |||
12 | int | ||
13 | sort_cb(const void *d1, const void *d2) | ||
14 | { | ||
15 | const Eina_Inlist *l1, *l2; | ||
16 | const struct my_struct *x1, *x2; | ||
17 | |||
18 | l1 = d1; | ||
19 | l2 = d2; | ||
20 | |||
21 | x1 = EINA_INLIST_CONTAINER_GET(l1, struct my_struct); | ||
22 | x2 = EINA_INLIST_CONTAINER_GET(l2, struct my_struct); | ||
23 | |||
24 | return x1->a - x2->a; | ||
25 | } | ||
26 | |||
27 | int | ||
28 | main(void) | ||
29 | { | ||
30 | struct my_struct *d, *cur; | ||
31 | Eina_Inlist *list, *itr, *tmp; | ||
32 | |||
33 | eina_init(); | ||
34 | |||
35 | d = malloc(sizeof(*d)); | ||
36 | d->a = 1; | ||
37 | d->b = 10; | ||
38 | list = eina_inlist_append(NULL, EINA_INLIST_GET(d)); | ||
39 | |||
40 | d = malloc(sizeof(*d)); | ||
41 | d->a = 2; | ||
42 | d->b = 20; | ||
43 | list = eina_inlist_append(list, EINA_INLIST_GET(d)); | ||
44 | |||
45 | d = malloc(sizeof(*d)); | ||
46 | d->a = 3; | ||
47 | d->b = 30; | ||
48 | list = eina_inlist_prepend(list, EINA_INLIST_GET(d)); | ||
49 | |||
50 | printf("list=%p\n", list); | ||
51 | EINA_INLIST_FOREACH(list, cur) | ||
52 | printf("\ta=%d, b=%d\n", cur->a, cur->b); | ||
53 | |||
54 | list = eina_inlist_promote(list, EINA_INLIST_GET(d)); | ||
55 | |||
56 | d = malloc(sizeof(*d)); | ||
57 | d->a = 4; | ||
58 | d->b = 40; | ||
59 | list = eina_inlist_append_relative(list, EINA_INLIST_GET(d), list); | ||
60 | |||
61 | list = eina_inlist_demote(list, EINA_INLIST_GET(d)); | ||
62 | |||
63 | list = eina_inlist_sort(list, sort_cb); | ||
64 | |||
65 | printf("list after sort=%p\n", list); | ||
66 | EINA_INLIST_FOREACH(list, cur) | ||
67 | printf("\ta=%d, b=%d\n", cur->a, cur->b); | ||
68 | |||
69 | tmp = eina_inlist_find(list, EINA_INLIST_GET(d)); | ||
70 | if (tmp) | ||
71 | cur = EINA_INLIST_CONTAINER_GET(tmp, struct my_struct); | ||
72 | else | ||
73 | cur = NULL; | ||
74 | |||
75 | if (d != cur) | ||
76 | printf("wrong node! cur=%p\n", cur); | ||
77 | |||
78 | list = eina_inlist_remove(list, EINA_INLIST_GET(d)); | ||
79 | free(d); | ||
80 | printf("list=%p\n", list); | ||
81 | for (itr = list; itr != NULL; itr = itr->next) | ||
82 | { | ||
83 | cur = EINA_INLIST_CONTAINER_GET(itr, struct my_struct); | ||
84 | printf("\ta=%d, b=%d\n", cur->a, cur->b); | ||
85 | } | ||
86 | |||
87 | while (list) | ||
88 | { | ||
89 | Eina_Inlist *aux = list; | ||
90 | list = eina_inlist_remove(list, list); | ||
91 | free(aux); | ||
92 | } | ||
93 | |||
94 | eina_shutdown(); | ||
95 | |||
96 | return 0; | ||
97 | } | ||