src/stack/utils/listlib.c File Reference

Implementation of a doubly linked list. More...


Functions

void list_add (LIST_NODE **ptr_list, LIST_NODE *ptr_node)
void list_cat (LIST_NODE **ptr_dst, LIST_NODE **ptr_src)
LIST_NODE * list_remove (LIST_NODE **ptr_list)
int list_remove_node (LIST_NODE **ptr_list, LIST_NODE *ptr_remove)
LIST_NODE * list_get_head (LIST_NODE **ptr_list)
LIST_NODE * list_get_next (LIST_NODE *ptr_list)
void list_clean (LIST_NODE *ptr_list, void free(void *ptr))
LIST_NODE * list_replicate (LIST_NODE *ptr_srcList, int size, void *alloc(UINT32 size), void free(void *ptr))


Detailed Description

Implementation of a doubly linked list.

NOTE: (C) Copyright 2008, Texas Instruments, Inc.

Function Documentation

void list_add ( LIST_NODE **  ptr_list,
LIST_NODE *  ptr_node 
)

Description
The function is called to add a node to the list.

Parameters:
[in] ptr_list This is the list to which the node is to be added.
[in] ptr_node This is the node which is to be added.
Return values:
Not Applicable

void list_cat ( LIST_NODE **  ptr_dst,
LIST_NODE **  ptr_src 
)

Description
The function is called to concatenate the src list to the end of the destination list.

Parameters:
[in] ptr_dst This is the head of the destination list.
[in] ptr_src This is the head of the source list.
Return values:
Not Applicable

void list_clean ( LIST_NODE *  ptr_list,
void   free(void *ptr) 
)

Description
The function is used to clean a list which has been replicated.

See also:
list_replicate
Parameters:
[in] ptr_list This is the pointer to list which has been replicated and now needs to be cleaned up.
[in] free This is the memory cleanup API which is invoked to clean the nodes in the list.
Return values:
Not Applicable.

LIST_NODE* list_get_head ( LIST_NODE **  ptr_list  ) 

Description
The function is used to get the head of the specific list

Parameters:
[in] ptr_list This is the pointer to the list.
Return values:
Head of the list (could be NULL if the list is empty)

LIST_NODE* list_get_next ( LIST_NODE *  ptr_list  ) 

Description
The function is used to get the next element in the list.

Parameters:
[in] ptr_list This is the pointer to the node in the list.
Return values:
Next element in the list. (could be NULL if this is the last element)

LIST_NODE* list_remove ( LIST_NODE **  ptr_list  ) 

Description
The function is called to remove the head node from the list.

Parameters:
[in] ptr_list This is the pointer to the list from where nodes will be removed.
Return values:
Pointer to the head of the list.

int list_remove_node ( LIST_NODE **  ptr_list,
LIST_NODE *  ptr_remove 
)

Description
The function is called to remove the specified node from the list.

Parameters:
[in] ptr_list This is the pointer to the list from where node will be removed.
[in] ptr_remove This is the node which is to be removed.
Return values:
Success - 0
Error - -1

LIST_NODE* list_replicate ( LIST_NODE *  ptr_srcList,
int  size,
void *  alloc(UINT32 size),
void   free(void *ptr) 
)

Description
The function is used to replicate a list. Replicating a list implies that each node in the source list is copied into the destination node and added to a destination list. This API involves memory allocation and callees are responsible for cleaning up the memory.

See also:
list_clean
Parameters:
[in] ptr_srcList This is the pointer to source list which needs to be replicated.
[in] size Size of the Node which is to be copied.
[in] alloc Memory Allocation API which is to be used.
[in] free Memory cleanup API which is to be used.
Return values:
Pointer to the head of the 'new' replicated list.


Copyright 2009, Texas Instruments Incorporated