Tizen Native API
Adding elements to Eina_List

Creating an Eina_List and adding elements to it is very easy and can be understood from an example: First thing is always to include Eina.h, for this example we also include stdio.h so we can use printf.

Just some boilerplate code, declaring some variable and initializing eina.

Here we add a sequence of elements to our list. By using append we add elements to the end of the list, so the list will look like this:
Full-size
There are a couple of interesting things happening here, first is that we are passing a NULL pointer to the first eina_list_append() call, when this is done a list is created. The other very important detail to notice is that the return value is attributed to the list variable, this needs to be done every time we use a a function that alters the contents of the list.

Now that we have a list with some elements in it we can look at its contents.

There are many ways of accessing elements in the list, including by its index:

Note:
It should be noted that the index starts at 0.

eina_list_append() is not the only way to add elements to a a list. A common requirement is to add an element in a specific position this can be accomplished using eina_list_append_relative() and eina_list_append_relative_list():

First "cain" is added after the second element(remember that indexes are 0 based) and then we add "zarek" after "cain".

Eina_List also has prepend analogs to append functions we have used so far:

With this additions our list now looks like this:
Full-size

Once done using the list it needs to be freed, and since we are done with eina that also need to be shutdown:

The full source code can be found on the examples folder on the eina_list_01.c file.