diff options
Diffstat (limited to 'libraries/eina/src/examples/eina_inlist_02.c')
-rw-r--r-- | libraries/eina/src/examples/eina_inlist_02.c | 65 |
1 files changed, 0 insertions, 65 deletions
diff --git a/libraries/eina/src/examples/eina_inlist_02.c b/libraries/eina/src/examples/eina_inlist_02.c deleted file mode 100644 index 4c16ec6..0000000 --- a/libraries/eina/src/examples/eina_inlist_02.c +++ /dev/null | |||
@@ -1,65 +0,0 @@ | |||
1 | // Compile with: | ||
2 | // gcc -g eina_inlist_02.c -o eina_inlist_02 `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 | main(void) | ||
14 | { | ||
15 | struct my_struct *d, *cur; | ||
16 | int i; | ||
17 | |||
18 | Eina_Inlist *inlist = NULL; | ||
19 | Eina_List *list = NULL, *l_itr, *l_next; | ||
20 | |||
21 | eina_init(); | ||
22 | |||
23 | for (i = 0; i < 100; i++) | ||
24 | { | ||
25 | d = malloc(sizeof(*d)); | ||
26 | d->a = i; | ||
27 | d->b = i * 10; | ||
28 | inlist = eina_inlist_append(inlist, EINA_INLIST_GET(d)); | ||
29 | if ((i % 2) == 0) | ||
30 | list = eina_list_prepend(list, d); | ||
31 | } | ||
32 | |||
33 | printf("inlist=%p\n", inlist); | ||
34 | EINA_INLIST_FOREACH(inlist, cur) | ||
35 | printf("\ta=%d, b=%d\n", cur->a, cur->b); | ||
36 | |||
37 | printf("list=%p\n", list); | ||
38 | EINA_LIST_FOREACH(list, l_itr, cur) | ||
39 | printf("\ta=%d, b=%d\n", cur->a, cur->b); | ||
40 | |||
41 | printf("inlist count=%d\n", eina_inlist_count(inlist)); | ||
42 | printf("list count=%d\n\n", eina_list_count(list)); | ||
43 | |||
44 | EINA_LIST_FOREACH_SAFE(list, l_itr, l_next, cur) | ||
45 | { | ||
46 | if ((cur->a % 3) == 0) | ||
47 | list = eina_list_remove_list(list, l_itr); | ||
48 | } | ||
49 | |||
50 | printf("inlist count=%d\n", eina_inlist_count(inlist)); | ||
51 | printf("list count=%d\n\n", eina_list_count(list)); | ||
52 | |||
53 | eina_list_free(list); | ||
54 | |||
55 | while (inlist) | ||
56 | { | ||
57 | Eina_Inlist *aux = inlist; | ||
58 | inlist = eina_inlist_remove(inlist, inlist); | ||
59 | free(aux); | ||
60 | } | ||
61 | |||
62 | eina_shutdown(); | ||
63 | |||
64 | return 0; | ||
65 | } | ||