src/list.h File Reference

List API. More...

#include <sys/types.h>
Include dependency graph for list.h:
This graph shows which files directly or indirectly include this file:

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.

Detailed Description

List API.

Definition in file list.h.


Define Documentation

#define _list_entry ( ptr,
ln_offset   )     (void *)((char *)(ptr)-(ln_offset))

Gets the entry containing a list node.

Parameters:
ptr pointer to a struct list_node
ln_offset the offset in bytes in the entry the list node is stored at
Returns:
a (type *) pointer to the entry

Definition at line 112 of file list.h.

#define list_entry ( ptr,
type,
member   )     ((type *)_list_entry((ptr), (size_t)&((type *)0)->member))

Gets the entry containing a list node.

Parameters:
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
Returns:
a (type *) pointer to the entry

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().

Parameters:
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().

Parameters:
last the list node to start from
node a struct list_node pointer that will hold the current node in each iteration

Definition at line 89 of file list.h.

#define list_for_each_reverse_safe ( last,
node,
tmp   ) 
Value:
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.

Parameters:
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   ) 
Value:
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.

Parameters:
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.

Parameters:
[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
Returns:
the operation error code

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().


Function Documentation

int _list_new ( list_t **  list,
size_t  ln_offset 
)

Creates a new doubly linked list.

Parameters:
[out] list the created list
ln_offset the offset of the struct list_node in the list entries
Returns:
the operation error code

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.

Parameters:
first the first node in the chain to delete
last the last node in the chain to delete
Returns:
the operation error code

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().

Here is the caller graph for this function:

int list_free ( list_t list  ) 

Frees a list.

This function does not free the data stored in the list.

Parameters:
list the list to free
Returns:
the operation error code

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().

Here is the caller graph for this function:

struct list_node* list_head ( list_t list  )  [read]

Gets the head node of a list.

Parameters:
list pointer to the list
Returns:
a list_node pointer to the head node of the 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().

Here is the caller graph for this function:

int list_insert_after ( struct list_node *  p,
struct list_node *  q 
)

Inserts a node after another node in a list.

Parameters:
p the node to which the new noded is inserted after
q the node to insert
Returns:
the operation error code

Definition at line 144 of file list.c.

References list_insert_chain_after().

Referenced by topo_visit().

Here is the call graph for this function:

Here is the caller graph for this function:

int list_insert_before ( struct list_node *  p,
struct list_node *  q 
)

Inserts a node before another node in a list.

Parameters:
p the node to which the new noded is inserted before
q the node to insert
Returns:
the operation error code

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().

Here is the caller graph for this function:

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.

Parameters:
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
Returns:
the operation error code

Definition at line 159 of file list.c.

Referenced by list_insert_after().

Here is the caller graph for this function:

struct list_node* list_tail ( list_t list  )  [read]

Gets the tail node of a list.

Parameters:
list pointer to the list
Returns:
a list_node pointer to the tail node of the 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().

Here is the caller graph for this function:


Generated on Sun Nov 15 15:27:48 2009 for libbls by  doxygen 1.6.1