Here it is reported an example of usage of the xanlib library.
In order to allocate a list (XanList) we have to write the following lines of code:
XanList *myList; myList = xanListNew(malloc, free, NULL);
In order to insert an element into a list for a single thread program, we have to write the following lines of code:
myList->insert(myList, myNewElementToInsert);
In order to delete the list without deleting the elements collected inside, we have to write the following line of code:
myList->destroyList(myList);
In the sequel, we provide the lines of code that iterates among a list.
XanListItem *item; myType *myData; item = myList->first(myList); while (item != NULL){ myData = (myType *) item->data; item = item->next; }