List API. More...
#include <sys/types.h>
Go to the source code of this file.
Defines | |
#define | list_for_each_safe(first, node, tmp) |
Iterate safely through the nodes in a list. | |
#define | list_for_each_reverse_safe(last, node, tmp) |
Reverse iterate safely through the nodes in a list. | |
#define | list_for_each(first, node) for ((node) = (first); (node) != (node)->next; (node) = (node)->next) |
Iterate through the nodes in a list. | |
#define | list_for_each_reverse(last, node) for ((node) = (last); (node) != (node)->prev; (node) = (node)->prev) |
Reverse iterate through the nodes in a list. | |
#define | list_entry(ptr, type, member) ((type *)_list_entry((ptr), (size_t)&((type *)0)->member)) |
Gets the entry containing a list node. | |
#define | _list_entry(ptr, ln_offset) (void *)((char *)(ptr)-(ln_offset)) |
Gets the entry containing a list node. | |
#define | list_new(pptr, type, member) _list_new((pptr), (size_t)&((type *)0)->member) |
Creates a new list. | |
Functions | |
int | _list_new (list_t **list, size_t ln_offset) |
Creates a new doubly linked list. | |
int | list_free (list_t *list) |
Frees a list. | |
struct list_node * | list_head (list_t *list) |
Gets the head node of a list. | |
struct list_node * | list_tail (list_t *list) |
Gets the tail node of a list. | |
int | list_insert_before (struct list_node *p, struct list_node *q) |
Inserts a node before another node in a list. | |
int | list_insert_after (struct list_node *p, struct list_node *q) |
Inserts a node after another node in a list. | |
int | list_insert_chain_after (struct list_node *p, struct list_node *start, struct list_node *end) |
Inserts a chain of nodes after another node in a list. | |
int | list_delete_chain (struct list_node *start, struct list_node *end) |
Deletes a chain of nodes from the list. |
List API.
Definition in file list.h.
#define _list_entry | ( | ptr, | |||
ln_offset | ) | (void *)((char *)(ptr)-(ln_offset)) |
#define list_entry | ( | ptr, | |||
type, | |||||
member | ) | ((type *)_list_entry((ptr), (size_t)&((type *)0)->member)) |
Gets the entry containing a list node.
ptr | pointer to a struct list_node | |
type | the type of the entry containing the list node | |
member | the member of the type storing the list node |
Definition at line 101 of file list.h.
Referenced by action_list_clear(), actions_make_private_copy(), bless_buffer_free(), bless_buffer_redo(), bless_buffer_save(), bless_buffer_undo(), find_seg_entry(), free_edge_list(), free_vertex_list(), overlap_graph_get_removed_edges(), overlap_graph_get_vertices_topo(), and undo_list_enforce_limit().
#define list_for_each | ( | first, | |||
node | ) | for ((node) = (first); (node) != (node)->next; (node) = (node)->next) |
Iterate through the nodes in a list.
If nodes are going to be altered or deleted during the iteration use list_for_each_safe().
first | the list node to start from | |
node | a struct list_node pointer that will hold the current node in each iteration |
Definition at line 76 of file list.h.
Referenced by bless_buffer_save().
#define list_for_each_reverse | ( | last, | |||
node | ) | for ((node) = (last); (node) != (node)->prev; (node) = (node)->prev) |
Reverse iterate through the nodes in a list.
If nodes are going to be altered or deleted during the iteration use list_for_each_reverse_safe().
last | the list node to start from | |
node | a struct list_node pointer that will hold the current node in each iteration |
#define list_for_each_reverse_safe | ( | last, | |||
node, | |||||
tmp | ) |
for ((node) = (last), (tmp) = (node)->prev; (node) != (node)->prev; \
(node) = (tmp), (tmp) = (tmp)->prev)
Reverse iterate safely through the nodes in a list.
This macro should be used when nodes are going to be altered or deleted during the iteration.
last | the list node to start from | |
node | a struct list_node pointer that will hold the current node in each iteration | |
tmp | a struct list_node pointer that will be used internally for safe iteration |
Definition at line 62 of file list.h.
Referenced by actions_make_private_copy().
#define list_for_each_safe | ( | first, | |||
node, | |||||
tmp | ) |
for ((node) = (first), (tmp) = (node)->next; (node) != (node)->next; \
(node) = (tmp), (tmp) = (tmp)->next)
Iterate safely through the nodes in a list.
This macro should be used when nodes are going to be altered or deleted during the iteration.
first | the list node to start from | |
node | a struct list_node pointer that will hold the current node in each iteration | |
tmp | a struct list_node pointer that will be used internally for safe iteration |
Definition at line 46 of file list.h.
Referenced by action_list_clear(), actions_make_private_copy(), bless_buffer_free(), free_edge_list(), free_vertex_list(), overlap_graph_get_removed_edges(), overlap_graph_get_vertices_topo(), and undo_list_enforce_limit().
#define list_new | ( | pptr, | |||
type, | |||||
member | ) | _list_new((pptr), (size_t)&((type *)0)->member) |
Creates a new list.
[out] | pptr | pointer to the created list |
type | the type of the entry containing the list nodes | |
member | the member of the type storing the list nodes |
Definition at line 124 of file list.h.
Referenced by bless_buffer_new(), buffer_action_multi_new(), overlap_graph_get_removed_edges(), overlap_graph_get_vertices_topo(), and segcol_list_new().
int _list_new | ( | list_t ** | list, | |
size_t | ln_offset | |||
) |
Creates a new doubly linked list.
[out] | list | the created list |
ln_offset | the offset of the struct list_node in the list entries |
Definition at line 47 of file list.c.
References list::head, list::ln_offset, and list::tail.
int list_delete_chain | ( | struct list_node * | first, | |
struct list_node * | last | |||
) |
Deletes a chain of nodes from the list.
This operation doesn't free the memory occupied by the nodes.
first | the first node in the chain to delete | |
last | the last node in the chain to delete |
Definition at line 186 of file list.c.
Referenced by action_list_clear(), actions_make_private_copy(), bless_buffer_redo(), bless_buffer_undo(), and undo_list_enforce_limit().
int list_free | ( | list_t * | list | ) |
Frees a list.
This function does not free the data stored in the list.
Definition at line 79 of file list.c.
Referenced by bless_buffer_free(), bless_buffer_new(), free_edge_list(), free_vertex_list(), overlap_graph_get_removed_edges(), overlap_graph_get_vertices_topo(), and segcol_list_new().
struct list_node* list_head | ( | list_t * | list | ) | [read] |
Gets the head node of a list.
Definition at line 96 of file list.c.
References list::head.
Referenced by action_list_clear(), actions_make_private_copy(), bless_buffer_can_redo(), bless_buffer_can_undo(), bless_buffer_free(), bless_buffer_save(), free_edge_list(), free_vertex_list(), overlap_graph_get_removed_edges(), overlap_graph_get_vertices_topo(), topo_visit(), and undo_list_enforce_limit().
int list_insert_after | ( | struct list_node * | p, | |
struct list_node * | q | |||
) |
Inserts a node after another node in a list.
p | the node to which the new noded is inserted after | |
q | the node to insert |
Definition at line 144 of file list.c.
References list_insert_chain_after().
Referenced by topo_visit().
int list_insert_before | ( | struct list_node * | p, | |
struct list_node * | q | |||
) |
Inserts a node before another node in a list.
p | the node to which the new noded is inserted before | |
q | the node to insert |
Definition at line 121 of file list.c.
Referenced by bless_buffer_redo(), bless_buffer_undo(), buffer_action_multi_add(), overlap_graph_get_removed_edges(), and undo_list_append().
int list_insert_chain_after | ( | struct list_node * | p, | |
struct list_node * | first, | |||
struct list_node * | last | |||
) |
Inserts a chain of nodes after another node in a list.
p | the node after which the node chain is inserted | |
first | the first node in the chain to insert | |
last | the last node in the chain to insert |
Definition at line 159 of file list.c.
Referenced by list_insert_after().
struct list_node* list_tail | ( | list_t * | list | ) | [read] |
Gets the tail node of a list.
Definition at line 108 of file list.c.
References list::tail.
Referenced by actions_make_private_copy(), bless_buffer_redo(), bless_buffer_undo(), buffer_action_multi_add(), overlap_graph_get_removed_edges(), and undo_list_append().