27 list->item_size = item_size;
30 list->free_item_fn = free_item_fn;
37 while (list->head != NULL) {
39 list->head = current->next;
41 if (list->free_item_fn) {
42 list->free_item_fn(current->data);
58 node->
data = calloc(1, list->item_size);
60 if (node->
data == NULL) {
67 node->
next = list->head;
70 if (list->tail == NULL) {
71 list->tail = list->head;
85 node->
data = calloc(1, list->item_size);
86 if (node->
data == NULL) {
93 if (list->length == 0) {
97 list->tail->next = node;
107 for (
ListItem *item = list->head; item != NULL; item = item->
next) {
108 if (compare_item_fn(data, item->data) ==
true) {
124 if (item == list->head) {
125 if (list->head == list->tail) {
129 list->head = list->head->next;
132 if (list->free_item_fn) {
133 list->free_item_fn(item->
data);
138 }
else if (item == list->tail) {
139 for (
ListItem *i = list->head; i != NULL; i = i->
next) {
140 if (i->next == list->tail) {
144 if (list->free_item_fn) {
145 list->free_item_fn(item->
data);
153 if (list->free_item_fn) {
154 list->free_item_fn(item->
data);
165 if (tmp == list->tail) {
177 for (
ListItem *item = list->head; item != NULL; item = item->
next) {
178 iterator_fn(item->data);
#define insecure_memzero(buf, len)
bool list_append(List *list, void *item)
bool list_prepend(List *list, void *item)
void list_delete(List *list, ListItem *item)
void list_iterate(List *list, IteratorFn iterator_fn)
ListItem * list_get(List *list, void *data, CompareItemFn compare_item_fn)
void list_create(List *list, int item_size, FreeItemFn free_item_fn)
void list_destroy(List *list)
bool(* CompareItemFn)(void *, void *)
void(* IteratorFn)(void *)
void(* FreeItemFn)(void *)
memcpy((char *) pInfo->slotDescription, s, l)