#include "errorcodes.h"
#include <stdlib.h>
Go to the source code of this file.
Data Structures | |
struct | list_node |
structure that is a single list node More... | |
struct | list |
structure to contain list information More... | |
Defines | |
#define | LIST_FOUND 1 |
a macro for the found return value in a match function | |
#define | LIST_NOT_FOUND 0 |
a macro for the not found return value in a match function | |
#define | LIST_FATAL -1 |
a macro for the fatal error return value in a match function | |
Typedefs | |
typedef list_node | list_node_t |
typedef for the list_node structure | |
typedef list | list_t |
typedef for the list structure | |
Functions | |
errorcode | list_init (list_t *list) |
initializes the list | |
errorcode | list_destroy (list_t *list, void(*func)(void *, void *), void *arg) |
deletes all entries from a list | |
errorcode | list_add (list_t *list, void *item) |
adds an item to the list | |
errorcode | list_find (list_t *list, int(*func)(void *, void *), void *arg, void **found_item) |
finds an item and returns a pointer to it through an argument. matches the item by a user specified function | |
errorcode | list_get (list_t *list, int index, void **item) |
gets the next item in the list after the index passed in | |
errorcode | list_remove (list_t *list, int(*func)(void *, void *), void *arg) |
removes an item from the list, matching the item by the user specified function | |
int | list_count (list_t *list) |
gets the number of items in the list | |
Variables | |
list_node | packed |
structure that is a single list node |
Definition in file list.h.
|
adds an item to the list
Definition at line 134 of file list.c. References errorcode, list::head, list_node::item, list::last_get, list::last_get_num, list_node_t, list_t, list_node::next, and list::size. Referenced by connlist_add(). |
|
gets the number of items in the list
Definition at line 208 of file list.c. References list_t, and list::size. Referenced by connlist_count(). |
|
deletes all entries from a list Use of the list functions after this function is called is undefined
Definition at line 42 of file list.c. References errorcode, list::head, list_node::item, list_node_t, list_t, list_node::next, and safe_free(). |
|
finds an item and returns a pointer to it through an argument. matches the item by a user specified function The first item that matches will be returned
Definition at line 64 of file list.c. References errorcode, list::head, list_node::item, LIST_FATAL, LIST_FOUND, list_node_t, LIST_NOT_FOUND, list_t, and list_node::next. Referenced by connlist_find(). |
|
gets the next item in the list after the index passed in an index is a integer which indexes into the list like it is an array. So, an index of 0 is the first element. If the index is negative, or higher than the number of elements, an error is returned. Make no assumptions about what item should be located at a given location, only assume that if this function is called in succession without other list functions called in between then the entire list will be returned with no duplicates.
Definition at line 96 of file list.c. References errorcode, list::head, list_node::item, list::last_get, list::last_get_num, list_node_t, list_t, list_node::next, and list::size. |
|
initializes the list Use of the list functions before this function is called is undefined
Definition at line 29 of file list.c. References errorcode, list::head, list::last_get, list::last_get_num, list_t, and list::size. Referenced by connlist_init(). |
|
removes an item from the list, matching the item by the user specified function Only the first item that matches will be removed
Definition at line 160 of file list.c. References errorcode, list::head, list_node::item, list::last_get, list::last_get_num, LIST_FATAL, LIST_FOUND, list_node_t, LIST_NOT_FOUND, list_t, list_node::next, safe_free(), and list::size. Referenced by connlist_forget(). |