

Creating an \mbox{\hyperlink{group__Eina__List__Group_ga3295e1210efea1fb0fd6acbf3cbc1f29}{Eina\+\_\+\+List}} and adding elements to it is very easy and can be understood from an example\+: First thing is always to include \mbox{\hyperlink{Eina_8h}{Eina.\+h}}, for this example we also include stdio.\+h so we can use printf. 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <stdio.h>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include <\mbox{\hyperlink{Eina_8h}{Eina.h}}>}}

\end{DoxyCodeInclude}
 Just some boilerplate code, declaring some variables and initializing eina. 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordtype}{int}}
\DoxyCodeLine{main(\textcolor{keywordtype}{int} argc, \textcolor{keywordtype}{char} **argv)}
\DoxyCodeLine{\{}
\DoxyCodeLine{   (void)argc;}
\DoxyCodeLine{   (void)argv;}
\DoxyCodeLine{   \mbox{\hyperlink{struct__Eina__List}{Eina\_List}} *list = NULL;}
\DoxyCodeLine{   \mbox{\hyperlink{struct__Eina__List}{Eina\_List}} *l;}
\DoxyCodeLine{   \textcolor{keywordtype}{void} *list\_data;}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eina__Main__Group_gafee4bfc0e509b6ffed6598edf6f4b3de}{eina\_init}}();}

\end{DoxyCodeInclude}
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\+:~\newline
  
\begin{DoxyImageNoCaption}
  \mbox{\includegraphics[width=\textwidth]{eina_list_example_01_a}}
\end{DoxyImageNoCaption}
 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{   list = \mbox{\hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{eina\_list\_append}}(list, \textcolor{stringliteral}{"{}tigh"{}});}
\DoxyCodeLine{   list = \mbox{\hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{eina\_list\_append}}(list, \textcolor{stringliteral}{"{}adar"{}});}
\DoxyCodeLine{   list = \mbox{\hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{eina\_list\_append}}(list, \textcolor{stringliteral}{"{}baltar"{}});}
\DoxyCodeLine{   list = \mbox{\hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{eina\_list\_append}}(list, \textcolor{stringliteral}{"{}roslin"{}});}

\end{DoxyCodeInclude}
There are a couple of interesting things happening here, first is that we are passing a NULL pointer to the first \mbox{\hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{eina\+\_\+list\+\_\+append()}} call, when this is done a list is created. The other {\bfseries{very}} important detail to notice is that the return value is attributed to the {\itshape 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. 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eina__List__Group_gac6efafc19f526d916cdb9757240a8773}{EINA\_LIST\_FOREACH}}(list, l, list\_data)}
\DoxyCodeLine{     printf(\textcolor{stringliteral}{"{}\%s\(\backslash\)n"{}}, (\textcolor{keywordtype}{char}*)list\_data);}

\end{DoxyCodeInclude}
 There are many ways of accessing elements in the list, including by its index\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{   printf(\textcolor{stringliteral}{"{}\(\backslash\)n"{}});}
\DoxyCodeLine{}
\DoxyCodeLine{   l = \mbox{\hyperlink{group__Eina__List__Group_gad4a1e3b0fdecd8ed4cb2ff592ceeb553}{eina\_list\_nth\_list}}(list, 1);}

\end{DoxyCodeInclude}
\begin{DoxyNote}{Note}
It should be noted that the index starts at 0.
\end{DoxyNote}
\mbox{\hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{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 \mbox{\hyperlink{group__Eina__List__Group_ga4676c189ca4bcfa22d7ecfbcd00200ae}{eina\+\_\+list\+\_\+append\+\_\+relative()}} and \mbox{\hyperlink{group__Eina__List__Group_gafa705d4483487e53d1be93a30e43c66d}{eina\+\_\+list\+\_\+append\+\_\+relative\+\_\+list()}}\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{   list = \mbox{\hyperlink{group__Eina__List__Group_gafa705d4483487e53d1be93a30e43c66d}{eina\_list\_append\_relative\_list}}(list, \textcolor{stringliteral}{"{}cain"{}}, l);}
\DoxyCodeLine{}
\DoxyCodeLine{   list = \mbox{\hyperlink{group__Eina__List__Group_ga4676c189ca4bcfa22d7ecfbcd00200ae}{eina\_list\_append\_relative}}(list, \textcolor{stringliteral}{"{}zarek"{}}, \textcolor{stringliteral}{"{}cain"{}});}

\end{DoxyCodeInclude}
First {\itshape \char`\"{}cain\char`\"{}} is added after the second element (remember that indexes are 0 based) and then we add {\itshape \char`\"{}zarek\char`\"{}} after {\itshape \char`\"{}cain\char`\"{}}.

\mbox{\hyperlink{group__Eina__List__Group_ga3295e1210efea1fb0fd6acbf3cbc1f29}{Eina\+\_\+\+List}} also has prepend analogs to append functions we have used so far\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{   list = \mbox{\hyperlink{group__Eina__List__Group_ga9f35bfc7c5b798014c3e0a74bc6f39ad}{eina\_list\_prepend}}(list, \textcolor{stringliteral}{"{}adama"{}});}
\DoxyCodeLine{}
\DoxyCodeLine{   list = \mbox{\hyperlink{group__Eina__List__Group_gad44370d18554ff250d2e9ddac4653caf}{eina\_list\_prepend\_relative}}(list, \textcolor{stringliteral}{"{}gaeta"{}}, \textcolor{stringliteral}{"{}cain"{}});}
\DoxyCodeLine{}
\DoxyCodeLine{   list = \mbox{\hyperlink{group__Eina__List__Group_ga03a77b1579ee83bcab4bc3d67375d4b1}{eina\_list\_prepend\_relative\_list}}(list, \textcolor{stringliteral}{"{}lampkin"{}}, l);}

\end{DoxyCodeInclude}
With this additions our list now looks like this\+:~\newline
  
\begin{DoxyImageNoCaption}
  \mbox{\includegraphics[width=\textwidth]{eina_list_example_01_b}}
\end{DoxyImageNoCaption}


Once done using the list it needs to be freed, and since we are done with eina that also need to be shutdown\+: 
\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eina__List__Group_gac6efafc19f526d916cdb9757240a8773}{EINA\_LIST\_FOREACH}}(list, l, list\_data)}
\DoxyCodeLine{     printf(\textcolor{stringliteral}{"{}\%s\(\backslash\)n"{}}, (\textcolor{keywordtype}{char}*)list\_data);}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eina__List__Group_ga608bd2fbf06293a1b794648990703ab4}{eina\_list\_free}}(list);}
\DoxyCodeLine{}
\DoxyCodeLine{   \mbox{\hyperlink{group__Eina__Main__Group_ga2c8b4020427108a30c44707af22c99d3}{eina\_shutdown}}();}
\DoxyCodeLine{}
\DoxyCodeLine{   \textcolor{keywordflow}{return} 0;}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 The full source code can be found on the examples folder on the \mbox{\hyperlink{eina_list_01_c}{eina\+\_\+list\+\_\+01.c}} file. 