Objective Systems, Inc.  
Home
About ASN.1
Products
Free Software
Documents
Services
Resources
Resellers
Customers
Careers
About Us
Contact Us
 

Google


Objective Systems, Inc.

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

Linked List Utility Functions
[C Runtime Common Functions]


Detailed Description

Linked list and stack utility functions are used to maintain linked lists and stacks used within the ASN.1 run-time library functions.


Functions

Asn1RTDListNode * rtDListAppend (ASN1CTXT *ctxt_p, Asn1RTDList *pList, void *pData)
void rtDListInit (Asn1RTDList *pList)
Asn1RTDListNode * rtDListInsert (ASN1CTXT *ctxt_p, Asn1RTDList *pList, int index, void *pData)
Asn1RTDListNode * rtDListInsertBefore (ASN1CTXT *ctxt_p, Asn1RTDList *pList, Asn1RTDListNode *node, void *pData)
Asn1RTDListNode * rtDListInsertAfter (ASN1CTXT *ctxt_p, Asn1RTDList *pList, Asn1RTDListNode *node, void *pData)
Asn1RTDListNode * rtDListFindByIndex (Asn1RTDList *pList, int index)
Asn1RTDListNode * rtDListFindByData (Asn1RTDList *pList, void *data)
int rtDListFindIndexByData (Asn1RTDList *pList, void *data)
void rtDListRemove (Asn1RTDList *pList, Asn1RTDListNode *node)
void rtDListFreeNodes (ASN1CTXT *ctxt_p, Asn1RTDList *pList)
void rtDListFreeAll (ASN1CTXT *ctxt_p, Asn1RTDList *pList)
int rtDListToArray (ASN1CTXT *ctxt_p, Asn1RTDList *pList, void **ppArray, ASN1UINT *pElements, int elemSize)
void rtDListAppendArray (ASN1CTXT *ctxt_p, Asn1RTDList *pList, ASN1ConstVoidPtr pArray, ASN1UINT numElements, int elemSize)
void rtDListAppendArrayCopy (ASN1CTXT *ctxt_p, Asn1RTDList *pList, ASN1ConstVoidPtr pArray, ASN1UINT numElements, int elemSize)
Asn1RTDListNode * rtDListAppendNode (ASN1CTXT *ctxt_p, Asn1RTDList *pList, void *pData)


Function Documentation

Asn1RTDListNode* rtDListAppend ASN1CTXT *  ctxt_p,
Asn1RTDList *  pList,
void *  pData
 

This function appends an item to the linked list structure. The data item is passed into the function as a void pointer that can point to any object of any type. The rtMemAlloc function is used to allocated the memory for the list node structure; therefore, all internal list memory will be released whenever rtMemFree is called. The pointer to the data item itself is stored in the node structure - a copy is not made.

Parameters:
ctxt_p A pointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls.
pList A pointer to a linked list structure onto which the data item is to be appended. A pointer to an updated linked list structure.
pData A pointer to a data item to be appended to the list.
Returns:
A pointer to an allocated node structure used to link the given data value into the list.

void rtDListAppendArray ASN1CTXT *  ctxt_p,
Asn1RTDList *  pList,
ASN1ConstVoidPtr  pArray,
ASN1UINT  numElements,
int  elemSize
 

This function appends an array items' pointers into a doublly linked list structure.

Parameters:
ctxt_p A pointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls.
pList A pointer to a linked list structure. A pointer to an updated linked list structure. The elements from the array will be appended to the end of the list.
pArray A pointer to the source array to be converted.
numElements The number of elements in the array.
elemSize The size of one element in the array. Use sizeof() operator to pass this parameter.

void rtDListAppendArrayCopy ASN1CTXT *  ctxt_p,
Asn1RTDList *  pList,
ASN1ConstVoidPtr  pArray,
ASN1UINT  numElements,
int  elemSize
 

This function appends a copy of an array's items into a doubly linked list structure. This memory for copies is allocated via calls to rtMemAlloc.

Parameters:
ctxt_p A pointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls.
pList A pointer to a linked list structure. A pointer to an updated linked list structure. The elements from the array will be appended to the end of the list.
pArray A pointer to the source array to be converted.
numElements The number of elements in the array.
elemSize The size of one element in the array. Use sizeof() operator to pass this parameter.

Asn1RTDListNode* rtDListFindByData Asn1RTDList *  pList,
void *  data
 

This function gets a node from a linked list structure that contains a specific data value. The comparison is done on the pointer values, not the data objects themselves.

Parameters:
pList A pointer to a linked list structure onto which the data item is to be appended.
data A pointer to the data item to be found in the list.
Returns:
A pointer to the found node structure. NULL is returned if a matching node could be found.

Asn1RTDListNode* rtDListFindByIndex Asn1RTDList *  pList,
int  index
 

This function gets a node from a linked list structure at a specified index.

Parameters:
pList A pointer to a linked list structure onto which the data item is to be appended.
index A relative zero-based index of the node in the list to be returned.
Returns:
The pointer to the found node structure. NULL, if the node is not found.

int rtDListFindIndexByData Asn1RTDList *  pList,
void *  data
 

This function gets a node's index from a linked list structure that contains a specific data value. The comparison is done on the pointer values, not the data objects themselves.

Parameters:
pList A pointer to a linked list structure onto which the data item is to be appended.
data A pointer to the data item to be found in the list.
Returns:
The index of the node that contains specified data. Negative one (-1) is returned if matching node could not be found.

void rtDListFreeAll ASN1CTXT *  ctxt_p,
Asn1RTDList *  pList
 

This function removes all nodes from the linked list structure and releases the memory that was allocated for storing nodes' structures (Asn1RTDListNode) and for data. The memory for data in each node must have been previously allocated with calls to rtMemAlloc, rtMemAllocZ, or rtMemRealloc functions.

Parameters:
ctxt_p A pointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls.
pList A pointer to a linked list structure onto which the data item is to be appended. A pointer to an updated linked list structure. A pointer to an empty linked list structure.

void rtDListFreeNodes ASN1CTXT *  ctxt_p,
Asn1RTDList *  pList
 

This function removes all nodes from the linked list and releases the memory that was allocated for storing nodes' structures (Asn1RTDListNode). The data will not be released.

Parameters:
ctxt_p A pointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls.
pList A pointer to a linked list structure onto which the data item is to be appended. A pointer to an updated linked list structure.

void rtDListInit Asn1RTDList *  pList  ) 
 

This function initializes a doubly linked list structure. It sets the number of elements to zero and sets al internal pointer values to NULL. A doubly linked-list structure is described by the Asn1RTDList type defined in asn1type.h. Nodes of the list are of type Asn1RTDListNode.

Memory for the structures is allocated using the rtMemAlloc run-time function and is maintained within the context structure that is a required parameter to all rtDList functions. This memory is released when rtMemFree is called or the Context is released. Unless otherwise noted, all data passed into the list functions is simply stored on the list by value (i.e. a deep-copy of the data is not done).

Parameters:
pList A pointer to a linked list structure to be initialized.

Asn1RTDListNode* rtDListInsert ASN1CTXT *  ctxt_p,
Asn1RTDList *  pList,
int  index,
void *  pData
 

This function inserts an item into the linked list structure. The data item is passed into the function as a void pointer that can point to an object of any type. The rtMemAlloc function is used to allocate the memory for the list node structure; therefore, all internal list memory will be released whenever the rtMemFree is called.

Parameters:
ctxt_p A pointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls.
pList A pointer to a linked list structure onto which the data item is to be appended. A pointer to an updated linked list structure.
index An index at which the specified item is to be inserted.
pData A pointer to a data item to be inserted to the list.
Returns:
A pointer to an allocated node structure used to link the given data value into the list.

Asn1RTDListNode* rtDListInsertAfter ASN1CTXT *  ctxt_p,
Asn1RTDList *  pList,
Asn1RTDListNode *  node,
void *  pData
 

This function inserts an item into a linked list structure after a specified node. The data item is passed into the function as a void pointer that can point to any type. The rtMemAlloc function is used to allocate the memory for the list structure; therefore, all internal list memory will be released whenever the rtMemFree is called.

Parameters:
ctxt_p A pointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls.
pList A pointer to a linked list structure onto which the data item is to be appended. A pointer to an updated linked list structure.
node A pointer to the node after which the specified item is to be inserted. It should already be in the linked list structure.
pData A pointer to a data item to be inserted to the list.
Returns:
A pointer to an allocated node structure used to link the given data value into the list

Asn1RTDListNode* rtDListInsertBefore ASN1CTXT *  ctxt_p,
Asn1RTDList *  pList,
Asn1RTDListNode *  node,
void *  pData
 

This function inserts an item into a linked list structure before a specified node. The data item is passed into the function as a void pointer that can point to an object of any type. The rtMemAlloc function is used to allocate the memory for the list node structure; therefore, all internal list memory will be released whenever the rtMemFree is called.

Parameters:
ctxt_p A pointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls.
pList A pointer to a linked list structure onto which the data item is to be appended. A pointer to an updated linked list structure.
node A pointer to the node before which the specified item is to be inserted. It should already be in the linked list structure.
pData A pointer to a data item to be inserted to the list.
Returns:
A pointer to an allocated node structure used to link the given data value into the list.

void rtDListRemove Asn1RTDList *  pList,
Asn1RTDListNode *  node
 

This function removes a node from the linked list structure. The rtMemAlloc function was used to allocate the memory for the list node structure, therefore, all internal list memory will be released whenever rtMemFree or rtMemFreePtr is called.

Parameters:
pList A pointer to a linked list structure onto which the data item is to be appended. A pointer to an updated linked list structure.
node A pointer to the node that is to be removed. It should already be in the linked list structure.

int rtDListToArray ASN1CTXT *  ctxt_p,
Asn1RTDList *  pList,
void **  ppArray,
ASN1UINT *  pElements,
int  elemSize
 

This function converts a doubly linked list to an array.

Parameters:
ctxt_p A pointer to a context structure. This provides a storage area for the function to store all working variables that must be maintained between function calls.
pList A pointer to a linked list structure. A pointer to an updated linked list structure.
ppArray A pointer to a pointer to a destination array. A pointer to filled destination array.
pElements A pointer to the number of elements already allocated in ppArray. If pElements is NULL, or pElements is less than the number of nodes in the list, then a new array is allocated and pointer is stored into ppArray. Memory is allocated via calls to the rtMemAlloc function. If not NULL, the pointer to the total number in the ppArray after the additional items were appended.
elemSize The size of one element in the array. Use sizeof() operator to pass this parameter.
Returns:
The number of elements in the returned array.


Copyright © 1997-2003 Objective Systems,Inc.
All Rights Reserved.
This document may be distributed in any form, electronic
or otherwise, provided that it is distributed in its entirety
and that the copyright and this notice are included.

This file was last modified on 14 Nov 2003.
ASN1C C/C++ Common Runtime, ASN1C v5.6x