1#ifndef COMPA_LINKED_LIST_HPP
2#define COMPA_LINKED_LIST_HPP
47#define EOUTOFMEM (-7 & 1 << 29)
Manage a free list (for internal use only).
Stores head and size of free list, as well as mutex for protection.
cmp_routine cmp_func
compare function to use
ListNode head
head, first item is stored at: head->next
long ListSize(LinkedList *list)
Returns the size of the list.
int ListDestroy(LinkedList *list, int freeItem)
Removes all memory associated with list nodes. Does not free LinkedList *list.
free_function free_func
free function to use
FreeList freeNodeList
free list to use
ListNode * ListPrev(LinkedList *list, ListNode *node)
Returns the previous item in the list.
void * ListDelNode(LinkedList *list, ListNode *dnode, int freeItem)
Removes a node from the list. The memory for the node is freed.
void(* free_function)(void *arg)
Function for freeing list items.
ListNode * ListAddBefore(LinkedList *list, void *item, ListNode *anode)
Adds a node before the specified node. Node gets added immediately before anode.
ListNode * ListNext(LinkedList *list, ListNode *node)
Returns the next item in the list.
ListNode * ListAddAfter(LinkedList *list, void *item, ListNode *bnode)
Adds a node after the specified node. Node gets added immediately after bnode.
ListNode * ListHead(LinkedList *list)
Returns the head of the list.
ListNode * ListAddHead(LinkedList *list, void *item)
Adds a node to the head of the list. Node gets immediately after list head.
ListNode * ListAddTail(LinkedList *list, void *item)
Adds a node to the tail of the list. Node gets added immediately before list.tail.
ListNode * ListTail(LinkedList *list)
Returns the tail of the list.
ListNode * ListFind(LinkedList *list, ListNode *start, void *item)
Finds the specified item in the list.
int ListInit(LinkedList *list, cmp_routine cmp_func, free_function free_func)
Initializes LinkedList. Must be called first and only once for List.
ListNode tail
tail, last item is stored at: tail->prev
int(* cmp_routine)(void *itemA, void *itemB)
Function for comparing list items. Returns 1 if itemA==itemB.
Linked list node. Stores generic item and pointers to next and prev.
Linked list (no protection).