\hypertarget{eina_inlist_02_8c-example}{}\section{eina\+\_\+inlist\+\_\+02.\+c}

\begin{DoxyCodeInclude}
\textcolor{comment}{// Compile with:}
\textcolor{comment}{// gcc -g eina\_inlist\_02.c -o eina\_inlist\_02 `pkg-config --cflags --libs eina`}

\textcolor{preprocessor}{#include <\hyperlink{Eina_8h}{Eina.h}>}
\textcolor{preprocessor}{#include <stdio.h>}

\textcolor{keyword}{struct }my\_struct \{
     \hyperlink{group__Eina__Inline__List__Group_gab30a76fcfa50307c797491705d60136a}{EINA\_INLIST};
     \textcolor{keywordtype}{int} a, b;
\};

\textcolor{keywordtype}{int}
main(\textcolor{keywordtype}{void})
\{
   \textcolor{keyword}{struct }my\_struct *d, *cur;
   \textcolor{keywordtype}{int} i;

   \hyperlink{struct__Eina__Inlist}{Eina\_Inlist} *inlist = NULL;
   \hyperlink{struct__Eina__List}{Eina\_List} *list = NULL, *l\_itr, *l\_next;

   \hyperlink{group__Eina__Main__Group_gabf448ada5bc81a07342b66c6f818ee5e}{eina\_init}();

   \textcolor{keywordflow}{for} (i = 0; i < 100; i++)
     \{
        d = malloc(\textcolor{keyword}{sizeof}(*d));
        d->a = i;
        d->b = i * 10;
        inlist = \hyperlink{group__Eina__Inline__List__Group_ga095c6abf8b0122e30271ce98c26c0524}{eina\_inlist\_append}(inlist, \hyperlink{group__Eina__Inline__List__Group_ga5bc991428e75557c6195f6b9e38321fb}{EINA\_INLIST\_GET}(d));
        \textcolor{keywordflow}{if} ((i % 2) == 0)
          list = \hyperlink{group__Eina__List__Group_ga9f35bfc7c5b798014c3e0a74bc6f39ad}{eina\_list\_prepend}(list, d);
     \}

   printf(\textcolor{stringliteral}{"inlist=%p\(\backslash\)n"}, inlist);
   \hyperlink{group__Eina__Inline__List__Group_ga65e496b9b16d527d23c1d735652b4e62}{EINA\_INLIST\_FOREACH}(inlist, cur)
     printf(\textcolor{stringliteral}{"\(\backslash\)ta=%d, b=%d\(\backslash\)n"}, cur->a, cur->b);

   printf(\textcolor{stringliteral}{"list=%p\(\backslash\)n"}, list);
   \hyperlink{group__Eina__List__Group_gad02f746a08ee0b12b7ed66d4bc0d71d8}{EINA\_LIST\_FOREACH}(list, l\_itr, cur)
     printf(\textcolor{stringliteral}{"\(\backslash\)ta=%d, b=%d\(\backslash\)n"}, cur->a, cur->b);

   printf(\textcolor{stringliteral}{"inlist count=%d\(\backslash\)n"}, \hyperlink{group__Eina__Inline__List__Group_ga20d6e4482cda609591cb504c7f0463f5}{eina\_inlist\_count}(inlist));
   printf(\textcolor{stringliteral}{"list count=%d\(\backslash\)n\(\backslash\)n"}, \hyperlink{group__Eina__List__Group_ga301729054a498a2df09a5f1dd760697e}{eina\_list\_count}(list));

   \hyperlink{group__Eina__List__Group_ga5b4d2aac696cd2558aaed03e3929d873}{EINA\_LIST\_FOREACH\_SAFE}(list, l\_itr, l\_next, cur)
     \{
        \textcolor{keywordflow}{if} ((cur->a % 3) == 0)
          list = \hyperlink{group__Eina__List__Group_ga7edefe0975beecc76c02525fb9200f5a}{eina\_list\_remove\_list}(list, l\_itr);
     \}

   printf(\textcolor{stringliteral}{"inlist count=%d\(\backslash\)n"}, \hyperlink{group__Eina__Inline__List__Group_ga20d6e4482cda609591cb504c7f0463f5}{eina\_inlist\_count}(inlist));
   printf(\textcolor{stringliteral}{"list count=%d\(\backslash\)n\(\backslash\)n"}, \hyperlink{group__Eina__List__Group_ga301729054a498a2df09a5f1dd760697e}{eina\_list\_count}(list));

   \hyperlink{group__Eina__List__Group_ga608bd2fbf06293a1b794648990703ab4}{eina\_list\_free}(list);

   \textcolor{keywordflow}{while} (inlist)
     \{
        \textcolor{keyword}{struct }my\_struct *aux = \hyperlink{group__Eina__Inline__List__Group_ga65080f9f858bdbeebc7ea46d17feb180}{EINA\_INLIST\_CONTAINER\_GET}(inlist,
                                                          \textcolor{keyword}{struct} my\_struct);
        inlist = \hyperlink{group__Eina__Inline__List__Group_gad84d4a8ad4c3392df4be8278ce10a274}{eina\_inlist\_remove}(inlist, inlist);
        free(aux);
     \}

   \hyperlink{group__Eina__Main__Group_ga6741fcaba116e31e96ce14dcfa03f568}{eina\_shutdown}();

   \textcolor{keywordflow}{return} 0;
\}
\end{DoxyCodeInclude}
 