XBinder  Version 2.6.x
Classes | Macros | Functions
Integer Stack Utility Functions

This is a simple stack structure with supporting push, pop, and peek functions. More...

Classes

struct  _OSRTIntStack
 This is the main stack structure. More...
 

Macros

#define OSRTISTK_DEFAULT_CAPACITY   100
 This is the default capacity that is used if zero is passed as the capacity argument to rtxIntStackInit.
 
#define rtxIntStackIsEmpty(stack)   (OSBOOL)((stack).index == 0)
 This macro tests if the stack is empty. More...
 

Functions

EXTERNRT int rtxIntStackInit (OSCTXT *pctxt, OSRTIntStack *pstack, size_t capacity)
 This function initializes a stack structure. More...
 
EXTERNRT int rtxIntStackPush (OSRTIntStack *pstack, OSINT32 value)
 This function pushes an item onto the stack. More...
 
EXTERNRT int rtxIntStackPeek (OSRTIntStack *pstack, OSINT32 *pvalue)
 This functions returns the data item on the top of the stack. More...
 
EXTERNRT int rtxIntStackPop (OSRTIntStack *pstack, OSINT32 *pvalue)
 This functions pops the data item on the top of the stack. More...
 

Detailed Description

This is a simple stack structure with supporting push, pop, and peek functions.

Macro Definition Documentation

◆ rtxIntStackIsEmpty

#define rtxIntStackIsEmpty (   stack)    (OSBOOL)((stack).index == 0)

This macro tests if the stack is empty.

Parameters
stackStack structure variable to be tested.

Definition at line 122 of file rtxIntStack.h.

Function Documentation

◆ rtxIntStackInit()

EXTERNRT int rtxIntStackInit ( OSCTXT pctxt,
OSRTIntStack pstack,
size_t  capacity 
)

This function initializes a stack structure.

It allocates the initial amount of memory required to store data and sets all working variables to their initil state.

Parameters
pctxtA pointer to the context with which the stack is associated.
pstackA pointer to a stack structure to be initialized.
capacityInitial capacity of the stack. This is the number of integer values that can be stored before the stack is expanded. Each expansion doubles the initial capacity value.
Returns
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.

◆ rtxIntStackPeek()

EXTERNRT int rtxIntStackPeek ( OSRTIntStack pstack,
OSINT32 *  pvalue 
)

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

Parameters
pstackA pointer to the stack structure.
pvalueA pointer to a variable to store the integer value of the item at the top of the stack.
Returns
Status of peek operation:
  • 0 (0) = success,
  • RTERR_ENDOFBUF if stack is empty

◆ rtxIntStackPop()

EXTERNRT int rtxIntStackPop ( OSRTIntStack pstack,
OSINT32 *  pvalue 
)

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

Parameters
pstackA pointer to the stack structure.
pvalueA pointer to a variable to store the integer value of the item at the top of the stack.
Returns
Status of pop operation:
  • 0 (0) = success,
  • RTERR_ENDOFBUF if stack is empty

◆ rtxIntStackPush()

EXTERNRT int rtxIntStackPush ( OSRTIntStack pstack,
OSINT32  value 
)

This function pushes an item onto the stack.

Parameters
pstackA pointer to the stack structure.
valueA pointer to the data item to be pushed on the stack.
Returns
Completion status of operation:
  • 0 (0) = success,
  • negative return value is error.