summaryrefslogtreecommitdiff
path: root/pages
diff options
context:
space:
mode:
authorPaul <pbrown@mykolab.com>2017-11-09 03:26:18 -0800
committerapache <apache@e5-web1.enlightenment.org>2017-11-09 03:26:18 -0800
commit4d03ebc1859f6a19db345b51fab84331d99e9bf3 (patch)
treec45ce93efa455a378593401dbaf2a934dcc706df /pages
parent39c6643699b9de9a307cab3c9ddbca7c81a64ca8 (diff)
Wiki page lists.md changed with summary [created] by Paul
Diffstat (limited to 'pages')
-rw-r--r--pages/develop/tutorial/c/hello-world-alternate.md.txt119
-rw-r--r--pages/eina-programming-guide/lists.md.txt647
2 files changed, 647 insertions, 119 deletions
diff --git a/pages/develop/tutorial/c/hello-world-alternate.md.txt b/pages/develop/tutorial/c/hello-world-alternate.md.txt
deleted file mode 100644
index 38a3defc5..000000000
--- a/pages/develop/tutorial/c/hello-world-alternate.md.txt
+++ /dev/null
@@ -1,119 +0,0 @@
1---
2~~Title: Tutorial 1: Hello World~~
3---
4
5# Tutorial 1: Hello World #
6
7This tutorial will guide you through the necessary steps to build your first "Hello World" example using the *Enlightenment Foundation Libraries* (EFL). Before continuing make sure you have read the [Setting up the Development Environment](/develop/setup/c/) guide.
8
9There is very little code in this first tutorial so don't worry if you have little coding experience. The main goal is to build and execute an application using EFL. You will need a basic knowledge of C to get started.
10
11## Step One: Includes ##
12
13Using your favorite text editor, create a text file and save it as ``hello-world.c``. Type in the following:
14
15```c
16#include <Eina.h>
17#include <Efl.h>
18#include <Elementary.h>
19```
20
21The EFL is split into several libraries. You only need to include the ones you actually want to use. In this tutorial we are calling methods from the ``Eina`` and ``Efl`` libraries, therefore we need to include the ``Eina.h`` and ``Efl.h`` headers.
22
23> **NOTE:**
24> The ``Elementary.h`` header is special and required for the program to compile. It will be removed soon, however.
25
26If you're not sure which libraries your program is actually using just look at the prefix of the EFL methods and macros. In this case we're using ``eina_``, ``EINA_``, ``efl_`` and ``EFL_``.
27
28You will explore the EFL libraries in greater depth in later tutorials. In the meantime, visit the [List of EFL Libraries](list-of-efl-libraries.md) for an overview of the purpose of each one.
29
30## Step Two: Main Function ##
31
32Instead of the ``main()`` function marking the standard C entry point EFL uses ``efl_main()``. Type the following underneath the includes section of your program:
33
34```c
35void
36efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
37{
38}
39```
40
41EFL takes care of all initialization tasks and calls your ``efl_main()`` method when everything is ready.
42
43We will focus on the ``efl_main()`` parameters in the following tutorial. In this one we're not using them, hence the ``EINA_UNUSED`` macro. This is optional but it gets rid of warnings regarding unused parameters so it's worth having.
44
45## Step Three: Print "Hello World" ##
46
47Type the following between the curly brackets of ``efl_main()``:
48
49```c
50 printf("Hello World!\n");
51```
52
53This is a regular C ``printf()`` which will output the "Hello World" string to the console.
54
55## Step Four: Exiting ##
56
57Any programs you create with EFL must always terminate by calling ``efl_exit()``. This is an important difference to the regular C ``main()``, where a program exits when it reaches the end of a method. Enter the following below your ``printf()``:
58
59```c
60 efl_exit(0);
61```
62
63The parameter ``efl_exit()`` is the value your program returns to the operating system.
64
65## Step Five: Automatic EFL setup and Shutdown ##
66
67This final piece of "boilerplate" code should be included at the end of every EFL program. Type the following at the very end of your program as the last line:
68
69```c
70EFL_MAIN()
71```
72
73This defines the real ``main()`` method required by C programs, which deals with initialization and deinitilization tasks. It also eventually calls the ``efl_main()`` method that you defined above.
74
75This is not mandatory but it simplifies the setup and shutdown processes considerably, so we are going to use it in this series of tutorials.
76
77## The Complete Program ##
78
79```c
80#include <Eina.h>
81#include <Efl.h>
82#include <Elementary.h>
83
84void
85efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
86{
87 printf("Hello World!\n");
88 efl_exit(0);
89}
90
91EFL_MAIN()
92```
93
94## Running the Program ##
95
96Save the program then build it as outlined in [Setting up the Development Environment](/develop/setup/c/#Building). If you are using the ``gcc`` compiler, run:
97
98```bash
99gcc -o hello-world hello-world.c `pkg-config --cflags --libs eina efl elementary` -DEFL_EO_API_SUPPORT=1 -DEFL_BETA_API_SUPPORT=1
100```
101
102If the systems displays no errors, your program should be ready. Test it by typing:
103
104```bash
105./hello-world
106```
107
108The words ``Hello World!`` will now appear on the screen.
109
110## Summary ##
111
112At the end of this tutorial you have learned:
113
114* Header files must be included for any EFL libraries you intend to use. Typically, these are ``Eina.h`` and ``Efl.h``.
115* Your main method should be ``efl_main()``.
116* Your EFL programs should always call ``efl_exit()`` at some stage.
117* Your EFL programs should include the ``EFL_MAIN()`` macro at the end so EFL can insert its own start-up and shutdown code.
118
119The next tutorial keeps introducing more basic concepts, and shows how to retrieve the command line parameters passed to your program. \ No newline at end of file
diff --git a/pages/eina-programming-guide/lists.md.txt b/pages/eina-programming-guide/lists.md.txt
new file mode 100644
index 000000000..71f82b3e9
--- /dev/null
+++ b/pages/eina-programming-guide/lists.md.txt
@@ -0,0 +1,647 @@
1{{page>index}}
2-------
3# Lists #
4
5The ``Eina_List`` is a double-linked list that can store data of any type as
6void pointers. It provides a set of functions to create and manipulate the
7list to avoid the access to the struct's fields, similar to a self-made
8double-link list.
9
10In addition to the previous and next node and its data, the ``Eina_List``
11nodes keep a reference to an accounting structure. The accounting structure is
12used to improve the performance of some functions. The structure is private
13and must not be modified.
14
15In an ``Eina_List``, everything is a "list": the list itself is a list where
16each node is a list as well.
17
18Eina provides 2 list types: the classic list (``Eina_List``) and an inline
19list (``Eina_Inlist``).
20
21## Creating and Destroying a List ##
22
23To use an ``Eina_List``:
24
25__**1**__. Declare the list with ``NULL`` as the default value:
26
27```c
28[...]
29int list()
30{
31 // Declaration of the Eina_List with NULL as default value;
32 Eina_List *list = NULL;
33[...]
34```
35
36__**2**__. Call the ``eina_list_append()`` function with the list and the data you
37want to append as parameters.
38
39The list must be a pointer to the first element of the list (or ``NULL``). The
40function returns a pointer to the list.
41
42```c
43[...]
44 // Creating the first element of the list
45 list = eina_list_append(list, "watch");
46
47 // Adding more elements
48 list = eina_list_append(list, "phone");
49 list = eina_list_append(list, "ivi");
50 list = eina_list_append(list, "notebook");
51[...]
52```
53
54__**3**__. When you no longer need the list, free it:
55
56```c
57[...]
58 // Free the Eina_List
59 eina_list_free(list);
60
61 return 0;
62}
63[...]
64```
65
66## Modifying List Content ##
67
68### To add data to a list ###
69
70 * To add data at the end of the list, use the ``eina_list_append()`` function. To add data at the top of the list, use ``eina_list_prepend()``. The functions work in the same way, only adding the data to different places.
71
72```c
73[...]
74list = eina_list_prepend(list, "set-top box");
75[...]
76```
77
78 * To insert data into the list after a specified data, use the ``eina_list_append_relative()`` function. As the last parameter, define the element after which the data is added. \\ \\ For example to append data after the "phone" element:
79
80```c
81[...]
82list = eina_list_append_relative(list, "single-board computer", "phone");
83[...]
84```
85
86 * To add a new entry before a specified data, use the ``eina_list_prepend_relative()`` function. It is similar to the ``eina_list_append_relative()`` function.
87
88```c
89[...]
90list = eina_list_prepend_relative(list, "ultrabook", "ivi");
91[...]
92```
93
94 * To append a list node to a linked list after a specified member, use the ``eina_list_append_relative_list()`` function. To prepend a list node to a linked list before a specified member, use the ``Eina_List * eina_list_prepend_relative_list()`` function.
95
96### To set data in a list member ###
97Use the ``eina_list_data_set()`` function. Pass the
98"list" (node) as the first argument and the data to set as the second.
99
100The following example also shows the usage of the ``eina_list_last()``
101function, which returns the last element of an ``Eina_List``.
102
103```c
104[...]
105// Setting new data for the last element
106eina_list_data_set(eina_list_last(list), eina_stringshare_add("Boris"));
107[...]
108```
109
110### To remove a node from the list ###
111
112Use the ``eina_list_remove()`` function. This function removes the first
113instance of the specified data from the given list.
114
115```c
116[...]
117list = eina_list_remove(list, "ultrabook");
118[...]
119```
120
121You can also remove a "list" (node) from a list using the
122``eina_list_remove_list()`` function. Pass the list you want to delete an
123element from and a 'list' (node) you want to delete.
124
125```c
126[...]
127Eina_List *app_list = NULL;
128Eina_List *to_remove = NULL;
129
130// Adding some elements to the list (using stringshares)
131app_list = eina_list_append(app_list, eina_stringshare_add("enna"));
132app_list = eina_list_append(app_list, eina_stringshare_add("ebird"));
133app_list = eina_list_append(app_list, eina_stringshare_add("calaos"));
134app_list = eina_list_append(app_list, eina_stringshare_add("rage"));
135app_list = eina_list_append(app_list, eina_stringshare_add("terminology"));
136app_list = eina_list_append(app_list, eina_stringshare_add("enlightenment"));
137app_list = eina_list_append(app_list, eina_stringshare_add("eyelight"));
138app_list = eina_list_append(app_list, eina_stringshare_add("ephoto"));
139
140// Finding the "list" to remove
141to_remove = eina_list_data_find_list(list, eina_string_share_add("enlightenment"));
142
143list = eina_list_remove_list(list, to_remove);
144[...]
145```
146
147### To move elements in a list ###
148
149You can use various function, such as ``eina_list_promote_list()`` that
150promotes an element to the top of the list or ``eina_list_demote_list()`` that
151puts the specified element at the end of the list. Remember that everything is
152a list so the second parameter represents the "list" (node) you want to move.
153Use the functions just like the ``eina_list_remove_list()`` function.
154
155```c
156[...]
157list = eina_list_promote_list(list, eina_list_data_find_list(list, "ivi"));
158[...]
159```
160
161### To reverse all the elements of a list ###
162
163Use the ``eina_list_reverse()`` function. To obtain a reversed copy of the
164list while keeping the initial list unchanged, use the
165``eina_list_reverse_clone()`` function.
166
167```c
168[...]
169Eina_List *rev_copy;
170
171app_list = eina_list_reverse(app_list);
172rev_copy = eina_list_reverse_clone(app_list);
173[...]
174```
175
176### To sort a list ###
177
178Use the ``eina_list_sort()`` function. This function takes a list which needs
179to be sorted, the maximum number of elements to be sorted, and a callback
180function that compares data. To sort all list elements, set the maximum number
181of elements to 0.
182
183```c
184[...]
185int sort_cb(const void *d1, const void *d2)
186{
187 const char *txt = d1;
188 const char *txt2 = d2;
189 if(!txt) return(1);
190 if(!txt2) return(-1);
191
192 return(strcmp(txt, txt2));
193}
194
195extern Eina_List *list;
196list = eina_list_sort(list, 0, sort_cb);
197[...]
198```
199
200### To merge 2 list into 1 ###
201
202Use the ``eina_list_merge()`` function. The ``eina_list_sorted_merge()``
203function merges 2 sorted lists according to the ordering function that you
204pass as the last argument.
205
206```c
207[...]
208int sort_cb(void *d1, void *d2)
209{
210 const char *txt = NULL;
211 const char *txt2 = NULL;
212 if(!d1) return(1);
213 if(!d2) return(-1);
214
215 return(strcmp((const char*)d1, (const char*)d2));
216}
217
218Eina_List *sorted1;
219Eina_List *sorted2;
220Eina_List *newlist;
221
222// Insert some values and sort your lists
223
224// Simply merge 2 lists without any process
225newlist = eina_list_merge(sorted1, sorted2);
226
227newlist = eina_list_sorted_merge(sorted1, sorted2, sort_cb);
228[...]
229```
230
231### To split a list ###
232
233Use the eina_list_split_list() function:
234 * The first parameter is the list to split.
235 * The second parameter is the "list" (element) after which the list is split.
236 * The last parameter is the head of the second list.
237
238```c
239[...]
240// Original list (left list)
241Eina_List *list = NULL;
242
243// New list (right list)
244Eina_List *other_list = NULL;
245
246// Eina_List (element)
247Eina_List *l;
248
249list = eina_list_append(list, "super tux");
250list = eina_list_append(list, "frozen bubble");
251list = eina_list_append(list, "lincity-ng");
252
253// Sorting the list (just for fun)
254list = eina_list_sort(list, 0, cmp_func);
255
256// Looking for the 'split' element
257l = eina_list_search_sorted_list(list, cmp_func, "frozen bubble");
258
259// Splitting the list
260list = eina_list_split_list(list, l, &other_list);
261[...]
262```
263
264### To copy a list ###
265
266Use the ``eina_list_clone()`` function. The function copies all the elements
267in the list in the exact same order.
268
269```c
270[...]
271Eina_List *app_list_copy;
272
273app_list_copy = eina_list_clone(app_list);
274[...]
275```
276
277## Accessing List Data ##
278
279### To find some data on your list ###
280
281Use the ``eina_list_data_find()`` function. Pass the list containing your data
282as the first parameter and the data you are looking for as the last one. The
283function returns the found member data pointer if found, ``NULL`` otherwise.
284
285The ``eina_list_data_find()`` function searches the list from the beginning to
286the end for the first member for which the data pointer is data. If it is
287found, the data is returned, otherwise ``NULL`` is returned. The function only
288compares pointers, which is why using ``Eina_Stringshare`` is very useful with
289lists, because it always returns the same pointer for the same string.
290
291```c
292[...]
293Eina_List *app_list = NULL;
294const char *res_str;
295
296// Adding some elements to the list (using stringshares)
297app_list = eina_list_append(app_list, eina_stringshare_add("enna"));
298app_list = eina_list_append(app_list, eina_stringshare_add("ebird"));
299app_list = eina_list_append(app_list, eina_stringshare_add("calaos"));
300app_list = eina_list_append(app_list, eina_stringshare_add("rage"));
301app_list = eina_list_append(app_list, eina_stringshare_add("terminology"));
302app_list = eina_list_append(app_list, eina_stringshare_add("enlightenment"));
303app_list = eina_list_append(app_list, eina_stringshare_add("eyelight"));
304app_list = eina_list_append(app_list, eina_stringshare_add("ephoto"));
305
306// Finding the data
307res_str = eina_list_data_find(list, eina_string_share_add("enlightenment"));
308if (res_str #### eina_stringshare_add("enlightenment"))
309 printf("Data is present");
310else
311 printf("Data not present");
312[...]
313```
314
315The above example returns "Data is present".
316
317The ``eina_list_data_find_list()`` function does the same thing as
318``eina_list_data_find()``, but returns an ``Eina_List``. For an example, see
319the ``eina_list_remove_list()`` function.
320
321You can access the data or a "list" (node) of an ``Eina_List`` using the
322``eina_list_nth()`` and ``eina_list_nth_list()`` functions. The first one returns a
323pointer to the data of the "n" element and the second a pointer to the "list".
324To access the data of the 3rd element of an ``Eina_List``:
325
326```c
327[...]
328const char *res;
329Eina_List *res_lst;
330
331res = eina_list_nth(app_list, 2);
332res_lst = eina_list_nth_list(app_list, 2);
333[...]
334```
335
336The ``res`` variable contains the pointer to the string "calaos". The
337``res_lst`` variable is the list containing "calaos".
338
339### To search for data in a list ###
340
341Select your function based on whether the list is sorted or unsorted.
342 * To search in an unsorted list, use the ``eina_list_search_unsorted()`` function:
343 * The first parameter is the list.
344 * The second parameter is a callback function for comparison.
345 * The last parameter is the data you are looking for.
346
347The ``eina_list_search_unsorted_list()`` function does the same but returns an
348"Eina_List".
349
350The following example shows 2 searches using both the
351``eina_list_search_unsorted()`` and ``eina_list_search_unsorted_list()``
352functions:
353
354```c
355[...]
356int search_list()
357{
358 // Declaring the list
359 Eina_List *list = NULL;
360 Eina_List *l;
361 // Little trick to use strcmp as Eina_Compare_Cb
362 Eina_Compare_Cb cmp_func = (Eina_Compare_Cb)strcmp;
363
364 void *data;
365 int cmp_result;
366
367 list = eina_list_append(list, "debian");
368 list = eina_list_append(list, "archlinux");
369 list = eina_list_append(list, "centos");
370
371 data = eina_list_search_unsorted(list, cmp_func, "archlinux");
372 l = eina_list_search_unsorted_list(list, cmp_func, "archlinux");
373 if (l->data != data)
374 {
375 eina_list_free(list);
376
377 return 1;
378 }
379
380 eina_list_free(list);
381
382 return 0;
383}
384[...]
385```
386 * To search in sorted lists, use the ``eina_list_search_sorted_list()`` and ``eina_list_search_sorted()`` functions. They work similarly as the ``eina_list_search_unsorted()`` function.
387
388### To get data from a list element ###
389
390Use the ``eina_list_data_get()`` function. The function returns the data
391contained in the given list.
392
393The following example uses the ``eina_list_next()`` function to move through
394the list in a statement.
395
396```c
397[...]
398int list_data_set()
399{
400 // Declaring the list
401 Eina_List *list = NULL;
402 // Eina_List in which to place the elements or lists
403 Eina_List *l;
404
405 void *list_data;
406
407 list = eina_list_append(list, eina_stringshare_add("Bertrand"));
408 list = eina_list_append(list, eina_stringshare_add("Cedric"));
409 list = eina_list_append(list, eina_stringshare_add("Nicolas"));
410 list = eina_list_append(list, eina_stringshare_add("Vincent"));
411 list = eina_list_append(list, eina_stringshare_add("Raoul"));
412 list = eina_list_append(list, eina_stringshare_add("Fabien"));
413 list = eina_list_append(list, eina_stringshare_add("Philippe"));
414 list = eina_list_append(list, eina_stringshare_add("billiob"));
415
416 for(l = list; l; l = eina_list_next(l))
417 // Printing the data returned by eina_list_data_get
418 printf("%s\n", (char*)eina_list_data_get(l));
419
420 EINA_LIST_FREE(list, list_data)
421 eina_stringshare_del(list_data);
422
423 return 0;
424}
425[...]
426```
427
428### To move in a list ###
429
430Use the ``eina_list_last()``, ``eina_list_next()``, or ``eina_list_prev()``
431functions to move to the last, next, or previous element in the list.
432
433The following example scrolls backwards starting from the end of the list:
434
435```c
436[...]
437
438for(l = eina_list_last(list); l; l = eina_list_prev(l))
439 printf("%s\n", (char*)eina_list_data_get(l));
440[...]
441```
442
443### To count the list elements ###
444
445Use the ``eina_list_count()`` function. The function returns the number of
446items in a list.
447
448```c
449[...]
450printf("List size: %d\n", eina_list_count(list));
451[...]
452```
453
454### To iterate through an array ###
455
456You can use various iterators:
457
458 * To iterate over a list from the beginning to the end, use the ``EINA_LIST_FOREACH`` macro:
459 * The first parameter is the list to iterate.
460 * The second parameter is an ``Eina_List *`` to hold the current "List" (node).
461 * The last parameter receives the current data during the run.
462
463The following example prints the data of each "List" (node) of the list:
464
465```c
466[...]
467Eina_List *list = NULL;
468Eina_List *l;
469void *list_data;
470
471list = eina_list_append(list, "ls");
472list = eina_list_append(list, "top");
473list = eina_list_append(list, "rmdir");
474list = eina_list_append(list, "uname");
475
476EINA_LIST_FOREACH(list, l, list_data)
477 printf("%s\n", (char*)list_data);
478
479eina_list_free(list);
480[...]
481```
482
483 * To iterate from the last element to the first, use the ``EINA_LIST_REVERSE_FOREACH`` macro. It works similarly as ``EINA_LIST_FOREACH()``.
484 * To iterate over a list from the beginning to the end, you can also use the
485``EINA_LIST_FOREACH_SAFE`` macro. It is called safe, because it stores the next "List" (node), so you can safely remove the current "List" (node) and continue the iteration.
486
487```c
488[...]
489Eina_List *list;
490Eina_List *l;
491Eina_List *l_next;
492char *data;
493
494list = eina_list_append(list, "enlightenment");
495list = eina_list_append(list, "enlightenment");
496list = eina_list_append(list, "enlightenment");
497list = eina_list_append(list, "enlightenment");
498
499// Using EINA_LIST_FOREACH_SAFE to free the elements that match "enlightenment"
500
501EINA_LIST_FOREACH_SAFE(list, l, l_next, data)
502 if (strcmp(data, "enlightenment") #### 0)
503 {
504 free(data);
505 list = eina_list_remove_list(list, l);
506 }
507[...]
508```
509
510 * To remove each list element while having access to the node's data, use the ``EINA_LIST_FREE`` macro. Pass the list and a pointer to hold the current data.
511
512```c
513[...]
514Eina_List *list;
515char *data;
516
517// List is filled
518
519EINA_LIST_FREE(list, data)
520 free(data);
521[...]
522```
523
524## Using an Inline List ##
525
526The ``Eina_Inlist`` is a special data type drawn to store nodes pointers in
527the same memory as data. This way the memory is less fragmented, but
528operations, such as sort and count, are slower. The ``Eina_Inlist`` has its
529own purpose, but if you do not understand what the purpose is, use the regular
530``Eina_List`` instead.
531
532The ``Eina_Inlist`` nodes can be part of a regular ``Eina_List``, simply added
533with the ``eina_list_append()`` or ``eina_list_prepend()`` functions.
534
535To use the inline list:
536
537__**1**__. Define the structure of the data before creating the inline list:
538
539```c
540[...]
541struct my_struct
542{
543 EINA_INLIST;
544 int a, b;
545};
546[...]
547```
548
549The structure is composed of 2 integers, the real data, and the
550``EINA_INLIST`` type which is composed of 3 pointers defining the inline list
551structure:
552 * ``Eina_Inlist * next``: next node
553 * ``Eina_Inlist * prev``: previous node
554 * ``Eina_Inlist * last``: last node
555
556__**2**__. To create the inlist nodes, allocate the memory and use the
557``eina_inlist_append()`` function:
558
559 * The first parameter is the existing list head or NULL to create a new list. \\ \\ The following example passes NULL to create a new list.
560 * The second parameter is the new list node, and it must not be NULL. \\ \\ You must use the ``EINA_INLIST_GET()`` macro to get the inlist object of the datastruct.
561
562```c
563[...]
564struct my_struct *d, *cur;
565Eina_Inlist *list, *itr, *tmp;
566
567d = malloc(sizeof(*d));
568d->a = 1;
569d->b = 10;
570
571list = eina_inlist_append(NULL, EINA_INLIST_GET(d));
572[...]
573```
574
575Repeat this operation for every new node:
576
577```c
578[...]
579d = malloc(sizeof(*d));
580d->a = 2;
581d->b = 20;
582list = eina_inlist_append(list, EINA_INLIST_GET(d));
583[...]
584```
585
586__**3**__. To add data to the inline list:
587
588 * Put data at the end of the inline list with the ``eina_inlist_prepend()`` function:
589
590```c
591[...]
592d = malloc(sizeof(*d));
593d->a = 3;
594d->b = 30;
595list = eina_inlist_prepend(list, EINA_INLIST_GET(d));
596[...]
597```
598
599 * Add a node before or after a given node with the ``eina_inlist_prepend_relative()`` and ``eina_inlist_append_relative()`` functions. \\ \\ In both functions, the first parameter is the target list, the second is the element you want to add, and the last is the reference element to place data after (in this case). Similarly as in a regular ``Eina_List``, everything is a list, so the last parameter is an ``Eina_Inlist`` typed variable.
600
601```c
602[...]
603d = malloc(sizeof(*d));
604d->a = 4;
605d->b = 40;
606list = eina_inlist_append_relative(list, EINA_INLIST_GET(d), list);
607[...]
608```
609
610__**4**__. To sort and iterate an inline list, to find and move list elements, and to perform other inline list operations, see the Inline List API.
611
612__**5**__. When the inline list is no longer needed, destroy it by looping over the list to free each ``EINA_INLIST`` structure and the data using allocated memory. Use the ``eina_inlist_remove()`` function on each node.
613
614In the following example, the ``EINA_INLIST_CONTAINER_GET()`` macro returns
615the container object of an inlist (the ``EINA_INLIST`` of ``my_struct``), and
616the list element is removed and the allocated memory of the container "object"
617is freed.
618
619```c
620[...]
621while (list)
622 {
623 struct my_struct *aux = EINA_INLIST_CONTAINER_GET(list, struct my_struct);
624
625 // Remove the current list element
626 list = eina_inlist_remove(list, list);
627 free(aux);
628 }
629[...]
630```
631
632### Further Reading ###
633
634[List API](https://build.enlightenment.org/job/nightly_efl_gcc_x86_64/lastSuccessfulBuild/artifact/doc/html/group__Eina__List__Group.html)
635: Functions that provide list management.
636
637[List Example 1](https://build.enlightenment.org/job/nightly_efl_gcc_x86_64/lastSuccessfulBuild/artifact/doc/html/eina_list_01_8c-example.html)
638: Example of list usage 1.
639
640[List Example 2](https://build.enlightenment.org/job/nightly_efl_gcc_x86_64/lastSuccessfulBuild/artifact/doc/html/eina_list_02_8c-example.html)
641: Example of list usage 2.
642
643[List Example 3](https://build.enlightenment.org/job/nightly_efl_gcc_x86_64/lastSuccessfulBuild/artifact/doc/html/eina_list_03_8c-example.html)
644: Example of list usage 3.
645
646[List Example 4](https://build.enlightenment.org/job/nightly_efl_gcc_x86_64/lastSuccessfulBuild/artifact/doc/html/eina_list_04_8c-example.html)
647: Example of list usage 4. \ No newline at end of file