diff options
Diffstat (limited to 'libraries/eina/src/examples/eina_array_01.c')
-rw-r--r-- | libraries/eina/src/examples/eina_array_01.c | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/libraries/eina/src/examples/eina_array_01.c b/libraries/eina/src/examples/eina_array_01.c deleted file mode 100644 index 1bae809..0000000 --- a/libraries/eina/src/examples/eina_array_01.c +++ /dev/null | |||
@@ -1,51 +0,0 @@ | |||
1 | //Compile with: | ||
2 | //gcc -g eina_array_01.c -o eina_array_01 `pkg-config --cflags --libs eina` | ||
3 | |||
4 | #include <stdio.h> | ||
5 | #include <string.h> | ||
6 | |||
7 | #include <Eina.h> | ||
8 | |||
9 | static Eina_Bool | ||
10 | _print(const void *container, void *data, void *fdata) | ||
11 | { | ||
12 | printf("%s\n", data); | ||
13 | return EINA_TRUE; | ||
14 | } | ||
15 | |||
16 | int | ||
17 | main(int argc, char **argv) | ||
18 | { | ||
19 | const char* strings[] = { | ||
20 | "helo", "hera", "starbuck", "kat", "boomer", | ||
21 | "hotdog", "longshot", "jammer", "crashdown", "hardball", | ||
22 | "duck", "racetrack", "apolo", "husker", "freaker", | ||
23 | "skulls", "bulldog", "flat top", "hammerhead", "gonzo" | ||
24 | }; | ||
25 | Eina_Array *array; | ||
26 | Eina_Array_Iterator iterator; | ||
27 | char *item; | ||
28 | unsigned int i; | ||
29 | |||
30 | eina_init(); | ||
31 | |||
32 | array = eina_array_new(10); | ||
33 | eina_array_step_set(array, sizeof(*array), 20); | ||
34 | |||
35 | for (i = 0; i < 20; i++) | ||
36 | eina_array_push(array, strdup(strings[i])); | ||
37 | |||
38 | printf("array count: %d\n", eina_array_count(array)); | ||
39 | eina_array_foreach(array, _print, NULL); | ||
40 | |||
41 | printf("Top gun: %s\n", (char*)eina_array_data_get(array, 2)); | ||
42 | |||
43 | while (eina_array_count(array)) | ||
44 | free(eina_array_pop(array)); | ||
45 | |||
46 | eina_array_free(array); | ||
47 | |||
48 | eina_shutdown(); | ||
49 | |||
50 | return 0; | ||
51 | } | ||