#include "list.h"
#include <stdlib.h>
#include <stdio.h>
Functions | |
void | list_add (struct list_head *new, struct list_head *head) |
void | list_add_tail (struct list_head *new, struct list_head *head) |
void | list_del (struct list_head *entry) |
void | list_del_init (struct list_head *entry) |
void | list_move (struct list_head *list, struct list_head *head) |
void | list_move_tail (struct list_head *list, struct list_head *head) |
void | list_splice (struct list_head *list, struct list_head *head) |
void | list_splice_init (struct list_head *list, struct list_head *head) |
int | list_empty (struct list_head *head) |
list_t * | list_get_new_node (void *data) |
Create new list node with given data. | |
list_t * | list_get_first_prev_node (list_t *list) |
Just get first previous element from list. | |
list_t * | list_get_next_node (list_t *list, list_t *previous_node, void **out_data) |
Gets next node for given node. | |
list_t * | list_get_new_list () |
Create and init list, it's node with null data. | |
list_t * | list_get_new_list_if_null (list_t *list) |
Create and init list, it is node with null data. | |
void | list_free (list_t *list) |
Free list, without nodes. Nodes not freed. | |
list_t * | list_free_empty (list_t *list) |
Free list. | |
void | list_free_node (list_t *node, void(*free_data_func)(void *data)) |
Free node. | |
void | list_free_with_nodes (list_t *list, void(*free_data_func)(void *data)) |
Free list and all nodes. | |
void | list_del_and_free_nodes_with_data (list_t *list, void *ref_to_data, void(*free_data_func)(void *data)) |
Free nodes with give data. | |
void | list_del_and_free_node (list_t *node, void(*free_data_func)(void *data)) |
Removes node from list and free it. | |
void | list_add_node (list_t *new_node, list_t *list) |
Add a new entry. | |
void | list_add_data (void *data, list_t *list) |
Add a new entry. | |
void | list_add_list (list_t *list, list_t *node) |
Add one list to another. | |
list_t * | list_copy_list (list_t *list) |
Create new list from another. | |
int | list_is_empty (list_t *list) |
Tests whether a list is empty. | |
int | list_is_null_or_empty (list_t *list) |
Tests whether a list is empty or equals NULL. | |
int | list_is_last_node (list_t *list, list_t *node) |
Tests whether a node is last in the list. | |
int | list_count_nodes_with_data (list_t *list, void *ref_to_data) |
Count nodes with given reference to data. |
list_add - add a new entry : new entry to be added : list head to add it after
Insert a new entry after the specified head. This is good for implementing stacks.
void list_add_data | ( | void * | data, | |
list_t * | list | |||
) |
Add a new entry.
Create new node with given data and add it to list. Insert a new entry after the specified head. This is good for implementing stacks.
data | data for new node. | |
list | list head to add it after. |
Add one list to another.
It not delete a list_t struct of addedd list, you need to remove it by youself, don't delete nodes (use
list | the new list to add. | |
node | the place to add it in the first list. |
Add a new entry.
Insert a new entry after the specified head. This is good for implementing stacks.
new_node | entry to be added. | |
list | list head to add it after. |
list_add_tail - add a new entry : new entry to be added : list head to add it before
Insert a new entry before the specified head. This is useful for implementing queues.
Create new list from another.
It create new list and set node's data field equals given list's nodes data (memory not allocating for data fields, sets references).
list | list for copy. |
int list_count_nodes_with_data | ( | list_t * | list, | |
void * | ref_to_data | |||
) |
Count nodes with given reference to data.
list | list for check. | |
ref_to_data | reference to data. |
void list_del | ( | struct list_head * | entry | ) |
list_del - deletes entry from list. : the element to delete from the list. Note: list_empty on entry does not return true after this, the entry is in an undefined state.
void list_del_and_free_node | ( | list_t * | node, | |
void(*)(void *data) | free_data_func | |||
) |
Removes node from list and free it.
node | node for remove and free. | |
free_data_func | reference for node data free function or NULL. |
void list_del_and_free_nodes_with_data | ( | list_t * | list, | |
void * | ref_to_data, | |||
void(*)(void *data) | free_data_func | |||
) |
Free nodes with give data.
If node has a data field with reference equals given, it will be removed.
list | list for check. | |
ref_to_data | reference to data or NULL, all nodes with data field equals NULL will be removed. | |
free_data_func | reference for node data free function or NULL. |
void list_del_init | ( | struct list_head * | entry | ) |
list_del_init - deletes entry from list and reinitialize it. : the element to delete from the list.
int list_empty | ( | struct list_head * | head | ) |
list_empty - tests whether a list is empty : the list to test.
void list_free | ( | list_t * | list | ) |
Free list, without nodes. Nodes not freed.
list | list. |
Free list.
Free list only if list is empty, no nodes.
list | list. |
void list_free_node | ( | list_t * | node, | |
void(*)(void *data) | free_data_func | |||
) |
Free node.
node | node for free. | |
free_data_func | reference for node data free function or NULL. |
void list_free_with_nodes | ( | list_t * | list, | |
void(*)(void *data) | free_data_func | |||
) |
Free list and all nodes.
list | list for free. | |
free_data_func | reference for node data free function or NULL. |
Just get first previous element from list.
list | list of elements. |
list_t* list_get_new_list | ( | ) |
Create and init list, it's node with null data.
Create and init list, it is node with null data.
Create new list if given equals NULL, otherwise return given list.
list | list for check. |
list_t* list_get_new_node | ( | void * | data | ) |
Create new list node with given data.
data | for storage in the node. |
Gets next node for given node.
Gets next node, if previous_node equals NULL or it last element in list, it gets firs element.
list | list. | |
previous_node | node for get next node in the list or NULL. | |
out_data | if not NULL, it will be equals a data field of new (next) node. It will be NULL if list equals NULL or empty. |
int list_is_empty | ( | list_t * | list | ) |
Tests whether a list is empty.
list | the list to test. |
Tests whether a node is last in the list.
list | the list to test. | |
node | node to test. |
int list_is_null_or_empty | ( | list_t * | list | ) |
Tests whether a list is empty or equals NULL.
list | the list to test. |
list_move - delete from one list and add as another's head : the entry to move : the head that will precede our entry
list_move_tail - delete from one list and add as another's tail : the entry to move : the head that will follow our entry
list_splice - join two lists : the new list to add. : the place to add it in the first list.
list_splice_init - join two lists and reinitialise the emptied list. : the new list to add. : the place to add it in the first list.
The list at is reinitialised