aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/eina/src/examples/eina_inarray_01.c
diff options
context:
space:
mode:
authorDavid Walter Seikel2012-04-22 09:20:32 +1000
committerDavid Walter Seikel2012-04-22 09:20:32 +1000
commit3ad3455551be0d7859ecb02290376206d5e66498 (patch)
tree497917e12b4d7f458dff9765d9b53f64c4e03fc3 /libraries/eina/src/examples/eina_inarray_01.c
parentUpdate EFL to latest beta. (diff)
downloadSledjHamr-3ad3455551be0d7859ecb02290376206d5e66498.zip
SledjHamr-3ad3455551be0d7859ecb02290376206d5e66498.tar.gz
SledjHamr-3ad3455551be0d7859ecb02290376206d5e66498.tar.bz2
SledjHamr-3ad3455551be0d7859ecb02290376206d5e66498.tar.xz
And actually include new files, plus elementary libraries.
Diffstat (limited to 'libraries/eina/src/examples/eina_inarray_01.c')
-rw-r--r--libraries/eina/src/examples/eina_inarray_01.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/libraries/eina/src/examples/eina_inarray_01.c b/libraries/eina/src/examples/eina_inarray_01.c
new file mode 100644
index 0000000..b9ab4e7
--- /dev/null
+++ b/libraries/eina/src/examples/eina_inarray_01.c
@@ -0,0 +1,52 @@
1//Compile with:
2//gcc -g eina_inarray_01.c -o eina_inarray_01 `pkg-config --cflags --libs eina`
3
4#include <Eina.h>
5
6int
7cmp(const void *a, const void *b)
8{
9 return *(int*)a > *(int*)b;
10}
11
12int main(int argc, char **argv)
13{
14 Eina_Inarray *iarr;
15 char ch, *ch2;
16 int a, *b;
17
18 eina_init();
19 iarr = eina_inarray_new(sizeof(char), 0);
20
21 ch = 'a';
22 eina_inarray_append(iarr, &ch);
23 ch = 'b';
24 eina_inarray_append(iarr, &ch);
25 ch = 'c';
26 eina_inarray_append(iarr, &ch);
27 ch = 'd';
28 eina_inarray_append(iarr, &ch);
29
30 printf("Inline array of chars:\n");
31 EINA_INARRAY_FOREACH(iarr, ch2)
32 printf("char: %c(pointer: %p)\n", *ch2, ch2);
33
34 eina_inarray_flush(iarr);
35 eina_inarray_setup(iarr, sizeof(int), 4);
36
37 a = 97;
38 eina_inarray_append(iarr, &a);
39 a = 98;
40 eina_inarray_append(iarr, &a);
41 a = 100;
42 eina_inarray_append(iarr, &a);
43 a = 99;
44 eina_inarray_insert_sorted(iarr, &a, cmp);
45
46 printf("Inline array of integers with %d elements:\n", eina_inarray_count(iarr));
47 EINA_INARRAY_FOREACH(iarr, b)
48 printf("int: %d(pointer: %p)\n", *b, b);
49
50 eina_inarray_free(iarr);
51 eina_shutdown();
52}