Eina_List and memory allocation example
//Compile with:
//gcc -g eina_list_04.c -o eina_list_04 `pkg-config --cflags --libs eina`
#include <stdio.h>
#include <Eina.h>
int
main(int argc, char **argv)
{
(void)argc;
(void)argv;
Eina_List *list = NULL;
void *list_data;
list = eina_list_append(list, eina_stringshare_add("calvin"));
list = eina_list_append(list, eina_stringshare_add("Leoben"));
list = eina_list_append(list, eina_stringshare_add("D'Anna"));
list = eina_list_append(list, eina_stringshare_add("Simon"));
list = eina_list_append(list, eina_stringshare_add("Doral"));
list = eina_list_append(list, eina_stringshare_add("Six"));
list = eina_list_append(list, eina_stringshare_add("Sharon"));
for(l = list; l; l = eina_list_next(l))
printf("%s\n", (char*)l->data);
for(l = eina_list_last(list); l; l = eina_list_prev(l))
printf("%s\n", (char*)eina_list_data_get(l));
EINA_LIST_FREE(list, list_data)
return 0;
}
Eina Utility library.
static Eina_List * eina_list_prev(const Eina_List *list)
Gets the list node prior to the specified list node.
EINA_API Eina_List * eina_list_append(Eina_List *list, const void *data)
Appends the given data to the given linked list.
Definition: eina_list.c:584
static void * eina_list_data_get(const Eina_List *list)
Gets the list node data member.
static Eina_List * eina_list_next(const Eina_List *list)
Gets the next list node after the specified list node.
#define EINA_LIST_FREE(list, data)
Definition for the macro to remove each list node while having access to each node's data.
Definition: eina_list.h:1629
static Eina_List * eina_list_last(const Eina_List *list)
Gets the last list node in the list.
EINA_API int eina_shutdown(void)
Shuts down the Eina library.
Definition: eina_main.c:379
EINA_API int eina_init(void)
Initializes the Eina library.
Definition: eina_main.c:291
EINA_API Eina_Stringshare * eina_stringshare_add(const char *str)
Retrieves an instance of a string for use in a program.
Definition: eina_stringshare.c:606
EINA_API void eina_stringshare_del(Eina_Stringshare *str)
Notes that the given string has lost an instance.
Definition: eina_stringshare.c:533
Type for a generic double linked list.
Definition: eina_list.h:318
void * data
Pointer to list element payload.
Definition: eina_list.h:319