Tizen Native API
Basic array usage

For this example we add stdlib.h, stdio.h and string.h for some convenience functions. The first thing to do to be able to use an Eina_Array is to include Eina.h:

Here we have a callback that prints the element given to it:

Now we create our entry point and declare some variables, nothing especial:

Before we can start using any array function we need to initialize eina:

So now to actually create our array. The only interesting thing here is the argument given to the eina_array_new() function. This argument sets how fast the array grows.

If you know before hand how big the array will need to be you should set the step to that. In our case we can set it to the number of strings we have and since we didn't do that in the eina_array_new() we can do it now:

Now let us populate our array with some strings:

Notice we use strdup, so we will have to free that memory later on.

Now lets check the size of the array:

And now we call a function on every member of our array to print it:

One of the strengths of Eina_Array over Eina_List is that it has very fast random access to elements, so this is very efficient:

And now we free up the memory allocated with the strdup()s:

And the array memory itself:

And finally shutdown eina and exit:

The full source code can be found in the examples folder in the eina_array_01.c file.