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

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

\textcolor{keyword}{struct }my\_struct \{
     \mbox{\hyperlink{group__Eina__Inline__List__Group_gab30a76fcfa50307c797491705d60136a}{EINA\_INLIST}};
     \mbox{\hyperlink{struct__Eina__Inlist}{Eina\_Inlist}} even;
     \textcolor{keywordtype}{int} a, b;
\};

\textcolor{preprocessor}{#define EVEN\_INLIST\_GET(Inlist) (& ((Inlist)->even))}

\textcolor{preprocessor}{#define EVEN\_INLIST\_CONTAINER\_GET(ptr, type) \(\backslash\)}
\textcolor{preprocessor}{   ((type *)((char *)ptr - offsetof(type, even)))}

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

   \mbox{\hyperlink{struct__Eina__Inlist}{Eina\_Inlist}} *list = NULL, *list\_even = NULL, *itr;

   \mbox{\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;
        list = \mbox{\hyperlink{group__Eina__Inline__List__Group_ga095c6abf8b0122e30271ce98c26c0524}{eina\_inlist\_append}}(list, \mbox{\hyperlink{group__Eina__Inline__List__Group_ga5bc991428e75557c6195f6b9e38321fb}{EINA\_INLIST\_GET}}(d));
        \textcolor{keywordflow}{if} ((i % 2) == 0)
          list\_even = \mbox{\hyperlink{group__Eina__Inline__List__Group_ga9b05113628965ac5865c35c8ace6562d}{eina\_inlist\_prepend}}(list\_even, EVEN\_INLIST\_GET(d));
     \}

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

   printf(\textcolor{stringliteral}{"list\_even=%p\(\backslash\)n"}, list\_even);
   \textcolor{keywordflow}{for} (itr = list\_even; itr != NULL; itr = itr->next)
     \{
        cur = EVEN\_INLIST\_CONTAINER\_GET(itr, \textcolor{keyword}{struct} my\_struct);
        printf(\textcolor{stringliteral}{"\(\backslash\)ta=%d, b=%d\(\backslash\)n"}, cur->a, cur->b);
     \}

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

   itr = list\_even;
   \textcolor{keywordflow}{while} (itr)
     \{
        \mbox{\hyperlink{struct__Eina__Inlist}{Eina\_Inlist}} *next = itr->\mbox{\hyperlink{struct__Eina__Inlist_ae95deba8e271f94f8ad8aecf7fdb5dde}{next}};
        cur = EVEN\_INLIST\_CONTAINER\_GET(itr, \textcolor{keyword}{struct} my\_struct);
        \textcolor{keywordflow}{if} ((cur->a % 3) == 0)
          list\_even = \mbox{\hyperlink{group__Eina__Inline__List__Group_gad84d4a8ad4c3392df4be8278ce10a274}{eina\_inlist\_remove}}(list\_even, itr);
        itr = next;
     \}
   printf(\textcolor{stringliteral}{"list count=%d\(\backslash\)n"}, \mbox{\hyperlink{group__Eina__Inline__List__Group_ga20d6e4482cda609591cb504c7f0463f5}{eina\_inlist\_count}}(list));
   printf(\textcolor{stringliteral}{"list\_even count=%d\(\backslash\)n\(\backslash\)n"}, \mbox{\hyperlink{group__Eina__Inline__List__Group_ga20d6e4482cda609591cb504c7f0463f5}{eina\_inlist\_count}}(list\_even));

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

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

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