Stack Utility Functions

Classes

struct  _OSRTStack

Defines

#define rtxStackIsEmpty(stack)   (OSBOOL)((stack).dlist.count == 0)

Typedefs

typedef struct _OSRTStack OSRTStack

Functions

OSRTStackrtxStackCreate (struct OSCTXT *pctxt)
void rtxStackInit (struct OSCTXT *pctxt, OSRTStack *pStack)
void * rtxStackPop (OSRTStack *pStack)
int rtxStackPush (OSRTStack *pStack, void *pData)
void * rtxStackPeek (OSRTStack *pStack)

Detailed Description

This is a simple stack structure with supporting push and pop functions. Different initialization routines are provided to permit different memory management schemes.


Define Documentation

#define rtxStackIsEmpty ( stack   )     (OSBOOL)((stack).dlist.count == 0)

This macro tests if the stack is empty.

Parameters:
stack Stack structure variable to be tested.

Function Documentation

OSRTStack* rtxStackCreate ( struct OSCTXT pctxt  ) 

This function creates a new stack structure. It allocates memory for the structure and calls rtxStackInit to initialize the structure.

Parameters:
pctxt A pointer to the context with which the stack is associated.
Returns:
A pointer to an allocated stack structure.
void rtxStackInit ( struct OSCTXT pctxt,
OSRTStack pStack 
)

This function initializes a stack structure. It sets the number of elements to zero and sets all internal pointer values to NULL.

Parameters:
pctxt A pointer to the context with which the stack is associated.
pStack A pointer to a stack structure to be initialized.
void* rtxStackPeek ( OSRTStack pStack  ) 

This functions returns the data item on the top of the stack.

Parameters:
pStack A pointer to the structure onto which the data item is to be pushed. The pointer updated to the stack structure
Returns:
Pointer to data item at top of stack or NULL if stack empty.
  • 0 (0) = success,
  • negative return value is error.
void* rtxStackPop ( OSRTStack pStack  ) 

This function pops an item off the stack.

Parameters:
pStack The pointer to the stack structure from which the value is to be popped. Pointer to the updated stack structure.
Returns:
The pointer to the item popped from the stack
int rtxStackPush ( OSRTStack pStack,
void *  pData 
)

This function pushes an item onto the stack.

Parameters:
pStack A pointer to the structure onto which the data item is to be pushed. The pointer updated to the stack structure
pData A pointer to the data item to be pushed on the stack.
Returns:
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.