diff options
author | David Walter Seikel | 2012-01-04 18:41:13 +1000 |
---|---|---|
committer | David Walter Seikel | 2012-01-04 18:41:13 +1000 |
commit | dd7595a3475407a7fa96a97393bae8c5220e8762 (patch) | |
tree | e341e911d7eb911a51684a7412ef7f7c7605d28e /libraries/eina/src/examples/eina_inlist_02.c | |
parent | Add the skeleton. (diff) | |
download | SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.zip SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.gz SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.bz2 SledjHamr-dd7595a3475407a7fa96a97393bae8c5220e8762.tar.xz |
Add the base Enlightenment Foundation Libraries - eina, eet, evas, ecore, embryo, and edje.
Note that embryo wont be used, but I'm not sure yet if you can build edje without it.
Diffstat (limited to 'libraries/eina/src/examples/eina_inlist_02.c')
-rw-r--r-- | libraries/eina/src/examples/eina_inlist_02.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/libraries/eina/src/examples/eina_inlist_02.c b/libraries/eina/src/examples/eina_inlist_02.c new file mode 100644 index 0000000..7d23f13 --- /dev/null +++ b/libraries/eina/src/examples/eina_inlist_02.c | |||
@@ -0,0 +1,64 @@ | |||
1 | // Compile with: | ||
2 | // gcc -g `pkg-config --cflags --libs eina` eina_inlist_01.c -o eina_inlist_01 | ||
3 | #include <Eina.h> | ||
4 | #include <stdio.h> | ||
5 | |||
6 | struct my_struct { | ||
7 | EINA_INLIST; | ||
8 | int a, b; | ||
9 | }; | ||
10 | |||
11 | int | ||
12 | main(void) | ||
13 | { | ||
14 | struct my_struct *d, *cur; | ||
15 | int i; | ||
16 | |||
17 | Eina_Inlist *inlist = NULL; | ||
18 | Eina_List *list = NULL, *l_itr, *l_next; | ||
19 | |||
20 | eina_init(); | ||
21 | |||
22 | for (i = 0; i < 100; i++) | ||
23 | { | ||
24 | d = malloc(sizeof(*d)); | ||
25 | d->a = i; | ||
26 | d->b = i * 10; | ||
27 | inlist = eina_inlist_append(inlist, EINA_INLIST_GET(d)); | ||
28 | if ((i % 2) == 0) | ||
29 | list = eina_list_prepend(list, d); | ||
30 | } | ||
31 | |||
32 | printf("inlist=%p\n", inlist); | ||
33 | EINA_INLIST_FOREACH(inlist, cur) | ||
34 | printf("\ta=%d, b=%d\n", cur->a, cur->b); | ||
35 | |||
36 | printf("list=%p\n", list); | ||
37 | EINA_LIST_FOREACH(list, l_itr, cur) | ||
38 | printf("\ta=%d, b=%d\n", cur->a, cur->b); | ||
39 | |||
40 | printf("inlist count=%d\n", eina_inlist_count(inlist)); | ||
41 | printf("list count=%d\n\n", eina_list_count(list)); | ||
42 | |||
43 | EINA_LIST_FOREACH_SAFE(list, l_itr, l_next, cur) | ||
44 | { | ||
45 | if ((cur->a % 3) == 0) | ||
46 | list = eina_list_remove_list(list, l_itr); | ||
47 | } | ||
48 | |||
49 | printf("inlist count=%d\n", eina_inlist_count(inlist)); | ||
50 | printf("list count=%d\n\n", eina_list_count(list)); | ||
51 | |||
52 | eina_list_free(list); | ||
53 | |||
54 | while (inlist) | ||
55 | { | ||
56 | Eina_Inlist *aux = inlist; | ||
57 | inlist = eina_inlist_remove(inlist, inlist); | ||
58 | free(aux); | ||
59 | } | ||
60 | |||
61 | eina_shutdown(); | ||
62 | |||
63 | return 0; | ||
64 | } | ||