MQTT C Client Libraries Internals
|
functions which apply to linked list structures. More...
#include "LinkedList.h"
#include <stdlib.h>
#include <string.h>
#include "Heap.h"
Functions | |
static int | ListUnlink (List *aList, void *content, int(*callback)(void *, void *), int freeContent) |
Removes and optionally frees an element in a list by comparing the content. More... | |
void | ListZero (List *newl) |
Sets a list structure to empty - all null values. More... | |
List * | ListInitialize (void) |
Allocates and initializes a new list structure. More... | |
void | ListAppendNoMalloc (List *aList, void *content, ListElement *newel, size_t size) |
Append an already allocated ListElement and content to a list. More... | |
ListElement * | ListAppend (List *aList, void *content, size_t size) |
Append an item to a list. More... | |
ListElement * | ListInsert (List *aList, void *content, size_t size, ListElement *index) |
Insert an item to a list at a specific position. More... | |
ListElement * | ListFind (List *aList, void *content) |
Finds an element in a list by comparing the content pointers, rather than the contents. More... | |
ListElement * | ListFindItem (List *aList, void *content, int(*callback)(void *, void *)) |
Finds an element in a list by comparing the content or pointer to the content. More... | |
int | ListDetach (List *aList, void *content) |
Removes but does not free an item in a list by comparing the pointer to the content. More... | |
int | ListRemove (List *aList, void *content) |
Removes and frees an item in a list by comparing the pointer to the content. More... | |
void * | ListDetachHead (List *aList) |
Removes and frees an the first item in a list. More... | |
int | ListRemoveHead (List *aList) |
Removes and frees an the first item in a list. More... | |
void * | ListPopTail (List *aList) |
Removes but does not free the last item in a list. More... | |
int | ListDetachItem (List *aList, void *content, int(*callback)(void *, void *)) |
Removes but does not free an element in a list by comparing the content. More... | |
int | ListRemoveItem (List *aList, void *content, int(*callback)(void *, void *)) |
Removes and frees an element in a list by comparing the content. More... | |
void | ListEmpty (List *aList) |
Removes and frees all items in a list, leaving the list ready for new items. More... | |
void | ListFree (List *aList) |
Removes and frees all items in a list, and frees the list itself. More... | |
void | ListFreeNoContent (List *aList) |
Removes and but does not free all items in a list, and frees the list itself. More... | |
ListElement * | ListNextElement (List *aList, ListElement **pos) |
Forward iteration through a list. More... | |
ListElement * | ListPrevElement (List *aList, ListElement **pos) |
Backward iteration through a list. More... | |
int | intcompare (void *a, void *b) |
List callback function for comparing integers. More... | |
int | stringcompare (void *a, void *b) |
List callback function for comparing C strings. More... | |
functions which apply to linked list structures.
These linked lists can hold data of any sort, pointed to by the content pointer of the ListElement structure. ListElements hold the points to the next and previous items in the list.
int intcompare | ( | void * | a, |
void * | b | ||
) |
List callback function for comparing integers.
a | first integer value |
b | second integer value |
ListElement* ListAppend | ( | List * | aList, |
void * | content, | ||
size_t | size | ||
) |
Append an item to a list.
aList | the list to which the item is to be added |
content | the list item content itself |
size | the size of the element |
void ListAppendNoMalloc | ( | List * | aList, |
void * | content, | ||
ListElement * | newel, | ||
size_t | size | ||
) |
Append an already allocated ListElement and content to a list.
Can be used to move an item from one list to another.
aList | the list to which the item is to be added |
content | the list item content itself |
newel | the ListElement to be used in adding the new item |
size | the size of the element |
int ListDetach | ( | List * | aList, |
void * | content | ||
) |
Removes but does not free an item in a list by comparing the pointer to the content.
aList | the list in which the search is to be conducted |
content | pointer to the content to look for |
void* ListDetachHead | ( | List * | aList | ) |
Removes and frees an the first item in a list.
aList | the list from which the item is to be removed |
int ListDetachItem | ( | List * | aList, |
void * | content, | ||
int(*)(void *, void *) | callback | ||
) |
Removes but does not free an element in a list by comparing the content.
A callback function is used to define the method of comparison for each element.
aList | the list in which the search is to be conducted |
content | pointer to the content to look for |
callback | pointer to a function which compares each element |
void ListEmpty | ( | List * | aList | ) |
Removes and frees all items in a list, leaving the list ready for new items.
aList | the list to which the operation is to be applied |
ListElement* ListFind | ( | List * | aList, |
void * | content | ||
) |
Finds an element in a list by comparing the content pointers, rather than the contents.
aList | the list in which the search is to be conducted |
content | pointer to the list item content itself |
ListElement* ListFindItem | ( | List * | aList, |
void * | content, | ||
int(*)(void *, void *) | callback | ||
) |
Finds an element in a list by comparing the content or pointer to the content.
A callback function is used to define the method of comparison for each element.
aList | the list in which the search is to be conducted |
content | pointer to the content to look for |
callback | pointer to a function which compares each element (NULL means compare by content pointer) |
void ListFree | ( | List * | aList | ) |
Removes and frees all items in a list, and frees the list itself.
aList | the list to which the operation is to be applied |
void ListFreeNoContent | ( | List * | aList | ) |
Removes and but does not free all items in a list, and frees the list itself.
aList | the list to which the operation is to be applied |
List* ListInitialize | ( | void | ) |
Allocates and initializes a new list structure.
ListElement* ListInsert | ( | List * | aList, |
void * | content, | ||
size_t | size, | ||
ListElement * | index | ||
) |
Insert an item to a list at a specific position.
aList | the list to which the item is to be added |
content | the list item content itself |
size | the size of the element |
index | the position in the list. If NULL, this function is equivalent to ListAppend. |
ListElement* ListNextElement | ( | List * | aList, |
ListElement ** | pos | ||
) |
Forward iteration through a list.
aList | the list to which the operation is to be applied |
pos | pointer to the current position in the list. NULL means start from the beginning of the list This is updated on return to the same value as that returned from this function |
void* ListPopTail | ( | List * | aList | ) |
Removes but does not free the last item in a list.
aList | the list from which the item is to be removed |
ListElement* ListPrevElement | ( | List * | aList, |
ListElement ** | pos | ||
) |
Backward iteration through a list.
aList | the list to which the operation is to be applied |
pos | pointer to the current position in the list. NULL means start from the end of the list This is updated on return to the same value as that returned from this function |
int ListRemove | ( | List * | aList, |
void * | content | ||
) |
Removes and frees an item in a list by comparing the pointer to the content.
aList | the list from which the item is to be removed |
content | pointer to the content to look for |
int ListRemoveHead | ( | List * | aList | ) |
Removes and frees an the first item in a list.
aList | the list from which the item is to be removed |
int ListRemoveItem | ( | List * | aList, |
void * | content, | ||
int(*)(void *, void *) | callback | ||
) |
Removes and frees an element in a list by comparing the content.
A callback function is used to define the method of comparison for each element
aList | the list in which the search is to be conducted |
content | pointer to the content to look for |
callback | pointer to a function which compares each element |
|
static |
Removes and optionally frees an element in a list by comparing the content.
A callback function is used to define the method of comparison for each element.
aList | the list in which the search is to be conducted |
content | pointer to the content to look for |
callback | pointer to a function which compares each element |
freeContent | boolean value to indicate whether the item found is to be freed |
void ListZero | ( | List * | newl | ) |
Sets a list structure to empty - all null values.
Does not remove any items from the list.
newl | a pointer to the list structure to be initialized |
int stringcompare | ( | void * | a, |
void * | b | ||
) |
List callback function for comparing C strings.
a | first integer value |
b | second integer value |