|
libUPnP
1.6.17
|
#include "FreeList.h"

Go to the source code of this file.
Data Structures | |
| struct | LISTNODE |
| struct | LINKEDLIST |
Macros | |
| #define | EOUTOFMEM (-7 & 1<<29) |
| #define | FREELISTSIZE 100 |
| #define | LIST_SUCCESS 1 |
| #define | LIST_FAIL 0 |
Typedefs | |
| typedef void(* | free_function )(void *arg) |
| typedef int(* | cmp_routine )(void *itemA, void *itemB) |
| typedef struct LISTNODE | ListNode |
| typedef struct LINKEDLIST | LinkedList |
Functions | |
| int | ListInit (LinkedList *list, cmp_routine cmp_func, free_function free_func) |
| Initializes LinkedList. Must be called first and only once for List. More... | |
| ListNode * | ListAddHead (LinkedList *list, void *item) |
| Adds a node to the head of the list. Node gets immediately after list head. More... | |
| ListNode * | ListAddTail (LinkedList *list, void *item) |
| Adds a node to the tail of the list. Node gets added immediately before list.tail. More... | |
| ListNode * | ListAddAfter (LinkedList *list, void *item, ListNode *bnode) |
| Adds a node after the specified node. Node gets added immediately after bnode. More... | |
| ListNode * | ListAddBefore (LinkedList *list, void *item, ListNode *anode) |
| Adds a node before the specified node. Node gets added immediately before anode. More... | |
| void * | ListDelNode (LinkedList *list, ListNode *dnode, int freeItem) |
| Removes a node from the list. The memory for the node is freed. More... | |
| int | ListDestroy (LinkedList *list, int freeItem) |
| Removes all memory associated with list nodes. Does not free LinkedList *list. More... | |
| ListNode * | ListHead (LinkedList *list) |
| Returns the head of the list. More... | |
| ListNode * | ListTail (LinkedList *list) |
| Returns the tail of the list. More... | |
| ListNode * | ListNext (LinkedList *list, ListNode *node) |
| Returns the next item in the list. More... | |
| ListNode * | ListPrev (LinkedList *list, ListNode *node) |
| Returns the previous item in the list. More... | |
| ListNode * | ListFind (LinkedList *list, ListNode *start, void *item) |
| Finds the specified item in the list. More... | |
| long | ListSize (LinkedList *list) |
| Returns the size of the list. More... | |
| typedef int(* cmp_routine)(void *itemA, void *itemB) |
Function for comparing list items. Returns 1 if itemA==itemB
| typedef void(* free_function)(void *arg) |
Function for freeing list items.
| typedef struct LINKEDLIST LinkedList |
Linked list (no protection).
Because this is for internal use, parameters are NOT checked for validity. The first item of the list is stored at node: head->next The last item of the list is stored at node: tail->prev If head->next=tail, then list is empty. To iterate through the list:
LinkedList g;
ListNode *temp = NULL;
for (temp = ListHead(g);temp!=NULL;temp = ListNext(g,temp)) {
}
Linked list node. Stores generic item and pointers to next and prev.
| ListNode* ListAddAfter | ( | LinkedList * | list, |
| void * | item, | ||
| ListNode * | bnode | ||
| ) |
Adds a node after the specified node. Node gets added immediately after bnode.
Precondition: The list has been initialized.
| list | Must be valid, non null, pointer to a linked list. |
| item | Item to be added. |
| bnode | Node to add after. |
References ListAddAfter(), and LINKEDLIST::size.
Referenced by ListAddAfter(), and ListAddHead().
| ListNode* ListAddBefore | ( | LinkedList * | list, |
| void * | item, | ||
| ListNode * | anode | ||
| ) |
Adds a node before the specified node. Node gets added immediately before anode.
Precondition: The list has been initialized.
| list | Must be valid, non null, pointer to a linked list. |
| item | Item to be added. |
| anode | Node to add in front of. |
References ListAddBefore(), and LINKEDLIST::size.
Referenced by ListAddBefore(), ListAddTail(), and TimerThreadSchedule().
| ListNode* ListAddHead | ( | LinkedList * | list, |
| void * | item | ||
| ) |
Adds a node to the head of the list. Node gets immediately after list head.
Precondition: The list has been initialized.
| list | Must be valid, non null, pointer to a linked list. |
| item | Item to be added. |
References LINKEDLIST::head, ListAddAfter(), and ListAddHead().
Referenced by ListAddHead().
| ListNode* ListAddTail | ( | LinkedList * | list, |
| void * | item | ||
| ) |
Adds a node to the tail of the list. Node gets added immediately before list.tail.
Precondition: The list has been initialized.
| list | Must be valid, non null, pointer to a linked list. |
| item | Item to be added. |
References ListAddBefore(), ListAddTail(), and LINKEDLIST::tail.
Referenced by BumpPriority(), ListAddTail(), SearchByTarget(), ThreadPoolAdd(), and TimerThreadSchedule().
| void* ListDelNode | ( | LinkedList * | list, |
| ListNode * | dnode, | ||
| int | freeItem | ||
| ) |
Removes a node from the list. The memory for the node is freed.
Precondition: The list has been initialized.
| list | Must be valid, non null, pointer to a linked list. |
| dnode | Node to delete. |
| freeItem | if !0 then item is freed using free function. If 0 (or free function is NULL) then item is not freed. |
References LINKEDLIST::free_func, LINKEDLIST::head, ListDelNode(), LINKEDLIST::size, and LINKEDLIST::tail.
Referenced by BumpPriority(), ListDelNode(), ListDestroy(), ThreadPoolRemove(), ThreadPoolShutdown(), TimerThreadRemove(), TimerThreadShutdown(), TimerThreadWorker(), UpnpUnRegisterClient(), and WorkerThread().
| int ListDestroy | ( | LinkedList * | list, |
| int | freeItem | ||
| ) |
Removes all memory associated with list nodes. Does not free LinkedList *list.
Precondition: The list has been initialized.
| list | Must be valid, non null, pointer to a linked list. |
| freeItem | if !0 then item is freed using free function. If 0 (or free function is NULL) then item is not freed. |
References FreeListDestroy(), LINKEDLIST::freeNodeList, LINKEDLIST::head, ListDelNode(), ListDestroy(), LINKEDLIST::size, and LINKEDLIST::tail.
Referenced by ListDestroy(), ThreadPoolShutdown(), TimerThreadInit(), TimerThreadShutdown(), UpnpRegisterRootDevice(), UpnpRegisterRootDevice2(), UpnpRegisterRootDevice4(), UpnpUnRegisterClient(), and UpnpUnRegisterRootDeviceLowPower().
| ListNode* ListFind | ( | LinkedList * | list, |
| ListNode * | start, | ||
| void * | item | ||
| ) |
Finds the specified item in the list.
Uses the compare function specified in ListInit. If compare function is NULL then compares items as pointers.
Precondition: The list has been initialized.
| list | Must be valid, non null, pointer to a linked list. |
| start | The node to start from, NULL if to start from beginning. |
| item | The item to search for. |
References LINKEDLIST::cmp_func, LINKEDLIST::head, ListFind(), and LINKEDLIST::tail.
Referenced by ListFind(), and ThreadPoolRemove().
| ListNode* ListHead | ( | LinkedList * | list | ) |
Returns the head of the list.
Precondition: The list has been initialized.
| list | Must be valid, non null, pointer to a linked list. |
References LINKEDLIST::head, ListHead(), and LINKEDLIST::size.
Referenced by CheckOtherHTTPHeaders(), ListHead(), ssdp_handle_ctrlpt_msg(), ThreadPoolShutdown(), TimerThreadRemove(), TimerThreadSchedule(), TimerThreadShutdown(), TimerThreadWorker(), UpnpUnRegisterClient(), and WorkerThread().
| int ListInit | ( | LinkedList * | list, |
| cmp_routine | cmp_func, | ||
| free_function | free_func | ||
| ) |
Initializes LinkedList. Must be called first and only once for List.
0 on success. EOUTOFMEM on failure. | list | Must be valid, non null, pointer to a linked list. |
| cmp_func | Function used to compare items. (May be NULL). |
| free_func | Function used to free items. (May be NULL). |
References LINKEDLIST::cmp_func, LINKEDLIST::free_func, FreeListInit(), LINKEDLIST::freeNodeList, LINKEDLIST::head, ListInit(), LINKEDLIST::size, and LINKEDLIST::tail.
Referenced by ListInit(), ThreadPoolInit(), TimerThreadInit(), UpnpRegisterClient(), UpnpRegisterRootDevice(), UpnpRegisterRootDevice2(), and UpnpRegisterRootDevice4().
| ListNode* ListNext | ( | LinkedList * | list, |
| ListNode * | node | ||
| ) |
Returns the next item in the list.
Precondition: The list has been initialized.
| list | Must be valid, non null, pointer to a linked list. |
| node | Node from the list. |
References ListNext(), and LINKEDLIST::tail.
Referenced by CheckOtherHTTPHeaders(), ListNext(), ssdp_handle_ctrlpt_msg(), TimerThreadRemove(), TimerThreadSchedule(), and TimerThreadShutdown().
| ListNode* ListPrev | ( | LinkedList * | list, |
| ListNode * | node | ||
| ) |
Returns the previous item in the list.
Precondition: The list has been initialized.
| list | Must be valid, non null, pointer to a linked list. |
| node | Node from the list. |
References LINKEDLIST::head, and ListPrev().
Referenced by ListPrev().
| long ListSize | ( | LinkedList * | list | ) |
Returns the size of the list.
Precondition: The list has been initialized.
| list | Must be valid, non null, pointer to a linked list. |
References ListSize(), and LINKEDLIST::size.
Referenced by ListSize().
| ListNode* ListTail | ( | LinkedList * | list | ) |
Returns the tail of the list.
Precondition: The list has been initialized.
| list | Must be valid, non null, pointer to a linked list. |
References ListTail(), LINKEDLIST::size, and LINKEDLIST::tail.
Referenced by ListTail().
1.8.3.1