
\begin{DoxyCodeInclude}
\textcolor{comment}{// Compile with:}
\textcolor{comment}{// gcc -g eina\_inlist\_01.c -o eina\_inlist\_01 `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}
sort\_cb(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *d1, \textcolor{keyword}{const} \textcolor{keywordtype}{void} *d2)
\{
   \textcolor{keyword}{const} \hyperlink{struct__Eina__Inlist}{Eina\_Inlist} *l1, *l2;
   \textcolor{keyword}{const} \textcolor{keyword}{struct }my\_struct *x1, *x2;

   l1 = d1;
   l2 = d2;

   x1 = \hyperlink{group__Eina__Inline__List__Group_ga65080f9f858bdbeebc7ea46d17feb180}{EINA\_INLIST\_CONTAINER\_GET}(l1, \textcolor{keyword}{struct} my\_struct);
   x2 = \hyperlink{group__Eina__Inline__List__Group_ga65080f9f858bdbeebc7ea46d17feb180}{EINA\_INLIST\_CONTAINER\_GET}(l2, \textcolor{keyword}{struct} my\_struct);

   \textcolor{keywordflow}{return} x1->a - x2->a;
\}

\textcolor{keywordtype}{int}
main(\textcolor{keywordtype}{void})
\{
   \textcolor{keyword}{struct }my\_struct *d, *cur;
   \hyperlink{struct__Eina__Inlist}{Eina\_Inlist} *list, *itr, *tmp;

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

   d = malloc(\textcolor{keyword}{sizeof}(*d));
   d->a = 1;
   d->b = 10;
   list = \hyperlink{group__Eina__Inline__List__Group_ga095c6abf8b0122e30271ce98c26c0524}{eina\_inlist\_append}(NULL, \hyperlink{group__Eina__Inline__List__Group_ga5bc991428e75557c6195f6b9e38321fb}{EINA\_INLIST\_GET}(d));

   d = malloc(\textcolor{keyword}{sizeof}(*d));
   d->a = 2;
   d->b = 20;
   list = \hyperlink{group__Eina__Inline__List__Group_ga095c6abf8b0122e30271ce98c26c0524}{eina\_inlist\_append}(list, \hyperlink{group__Eina__Inline__List__Group_ga5bc991428e75557c6195f6b9e38321fb}{EINA\_INLIST\_GET}(d));

   d = malloc(\textcolor{keyword}{sizeof}(*d));
   d->a = 3;
   d->b = 30;
   list = \hyperlink{group__Eina__Inline__List__Group_ga9b05113628965ac5865c35c8ace6562d}{eina\_inlist\_prepend}(list, \hyperlink{group__Eina__Inline__List__Group_ga5bc991428e75557c6195f6b9e38321fb}{EINA\_INLIST\_GET}(d));

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

   list = \hyperlink{group__Eina__Inline__List__Group_gaaad2933c1da2d5f11a07d7c259df89fe}{eina\_inlist\_promote}(list, \hyperlink{group__Eina__Inline__List__Group_ga5bc991428e75557c6195f6b9e38321fb}{EINA\_INLIST\_GET}(d));

   d = malloc(sizeof(*d));
   d->a = 4;
   d->b = 40;
   list = \hyperlink{group__Eina__Inline__List__Group_ga188a035d7159c3856d8b608187064534}{eina\_inlist\_append\_relative}(list, 
      \hyperlink{group__Eina__Inline__List__Group_ga5bc991428e75557c6195f6b9e38321fb}{EINA\_INLIST\_GET}(d), list);

   list = \hyperlink{group__Eina__Inline__List__Group_gabea5613e6992fb5bc07271c999f439e0}{eina\_inlist\_demote}(list, \hyperlink{group__Eina__Inline__List__Group_ga5bc991428e75557c6195f6b9e38321fb}{EINA\_INLIST\_GET}(d));

   list = \hyperlink{group__Eina__Inline__List__Group_gac1132bfed4e77a5b63b0fb81d46f20c9}{eina\_inlist\_sort}(list, sort\_cb);

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

   tmp = \hyperlink{group__Eina__Inline__List__Group_ga2e073030214eaf33c2a0200364ebae5e}{eina\_inlist\_find}(list, \hyperlink{group__Eina__Inline__List__Group_ga5bc991428e75557c6195f6b9e38321fb}{EINA\_INLIST\_GET}(d));
   if (tmp)
     cur = \hyperlink{group__Eina__Inline__List__Group_ga65080f9f858bdbeebc7ea46d17feb180}{EINA\_INLIST\_CONTAINER\_GET}(tmp, struct my\_struct);
   else
     cur = NULL;

   if (d != cur)
     printf("wrong node! cur=%p\(\backslash\)n", cur);

   list = \hyperlink{group__Eina__Inline__List__Group_gad84d4a8ad4c3392df4be8278ce10a274}{eina\_inlist\_remove}(list, \hyperlink{group__Eina__Inline__List__Group_ga5bc991428e75557c6195f6b9e38321fb}{EINA\_INLIST\_GET}(d));
   free(d);
   printf("list=%p\(\backslash\)n", list);
   for (itr = list; itr != NULL; itr = itr->next)
     \{
        cur = \hyperlink{group__Eina__Inline__List__Group_ga65080f9f858bdbeebc7ea46d17feb180}{EINA\_INLIST\_CONTAINER\_GET}(itr, \textcolor{keyword}{struct} my\_struct);
        printf(\textcolor{stringliteral}{"\(\backslash\)ta=%d, b=%d\(\backslash\)n"}, cur->a, cur->b);
     \}

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

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

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