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
|
//Compile with:
//gcc -g eina_array_01.c -o eina_array_01 `pkg-config --cflags --libs eina`
#include <stdio.h>
#include <string.h>
#include <Eina.h>
static Eina_Bool
_print(const void *container, void *data, void *fdata)
{
printf("%s\n", data);
return EINA_TRUE;
}
int
main(int argc, char **argv)
{
const char* strings[] = {
"helo", "hera", "starbuck", "kat", "boomer",
"hotdog", "longshot", "jammer", "crashdown", "hardball",
"duck", "racetrack", "apolo", "husker", "freaker",
"skulls", "bulldog", "flat top", "hammerhead", "gonzo"
};
Eina_Array *array;
Eina_Array_Iterator iterator;
char *item;
unsigned int i;
eina_init();
array = eina_array_new(10);
eina_array_step_set(array, sizeof(*array), 20);
for (i = 0; i < 20; i++)
eina_array_push(array, strdup(strings[i]));
printf("array count: %d\n", eina_array_count(array));
eina_array_foreach(array, _print, NULL);
printf("Top gun: %s\n", (char*)eina_array_data_get(array, 2));
while (eina_array_count(array))
free(eina_array_pop(array));
eina_array_free(array);
eina_shutdown();
return 0;
}
|