GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> XLX / dev > parser / rhel4-32


Interface   Data Structures   File List   Data Fields   Globals  

stack.c File Reference

Stack manipulation functions. More...

#include <XLX_p.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>

Functions

int XLX_initStack (XLX_stack *stack, unsigned int limit)
 Initialise a stack.
void XLX_endStack (XLX_stack *stack)
 Free the memory allocated to a stack.
void XLX_destroyStack (XLX_stack *stack, XLX_pDelete dFn)
 Free the memory allocated to a stack and its elements.
int XLX_push (XLX_stack *stack, void *ptr)
 Put a new item on the top of a stack.
void * XLX_pop (XLX_stack *stack)
 Remove and return the top item on a stack.
void * XLX_peek (XLX_stack *stack, unsigned int depth)
 Look at an item on a stack without removing it.
void XLX_dump (XLX_stack *stack)
 Print out the stack information.


Detailed Description

Stack manipulation functions.

Author:
James Swain & Owen Saxton
Id
stack.c,v 1.10 2011/03/25 21:01:49 saxton Exp

Function Documentation

void XLX_destroyStack ( XLX_stack stack,
XLX_pDelete  dFn 
)

Free the memory allocated to a stack and its elements.

Parameters:
stack Stack to end
dFn Function to call to delete objects on the stack

References XLX_endStack(), and XLX_pop().

void XLX_dump ( XLX_stack stack  ) 

Print out the stack information.

Parameters:
stack Stack to dump

References _XLX_stack::base, _XLX_stack::limit, and _XLX_stack::used.

void XLX_endStack ( XLX_stack stack  ) 

Free the memory allocated to a stack.

Parameters:
stack Stack to free

References _XLX_stack::base, _XLX_stack::limit, and _XLX_stack::used.

Referenced by XLX_destroyStack().

int XLX_initStack ( XLX_stack stack,
unsigned int  limit 
)

Initialise a stack.

This routine allocates memory to hold the stack contents and sets the limit and used values.

Parameters:
stack Stack to initialise
limit Size of the stack
Return values:
0 If the stack was successfully initialised
-1 If there was an error allocating memory for the stack

References _XLX_stack::base, _XLX_stack::limit, and _XLX_stack::used.

Referenced by XLX_initState().

void* XLX_peek ( XLX_stack stack,
unsigned int  depth 
)

Look at an item on a stack without removing it.

Parameters:
stack Stack to peek at
depth Depth from the top of the stack of item to peek at
Returns:
Item on the top of the stack

References _XLX_stack::base, and _XLX_stack::used.

Referenced by XLX_character(), XLX_character_tag(), and XLX_start().

void* XLX_pop ( XLX_stack stack  ) 

Remove and return the top item on a stack.

Parameters:
stack Stack to pop item off
Returns:
Item popped off the top of the stack

References _XLX_stack::base, and _XLX_stack::used.

Referenced by XLX_character_tag(), XLX_destroyStack(), and XLX_end().

int XLX_push ( XLX_stack stack,
void *  ptr 
)

Put a new item on the top of a stack.

If the stack is already full, its size is doubled.

Parameters:
stack Stack to push item onto
ptr Pointer to push onto stack
Return values:
0 If the item is added successfully
-1 If the stack needs to be extended to accomodate the new item and the memory allocation failed

References _XLX_stack::base, _XLX_stack::limit, and _XLX_stack::used.

Referenced by XLX_character_tag(), XLX_initState(), and XLX_start().


Generated on Mon Mar 28 10:24:08 2011 by  doxygen 1.5.8