\hypertarget{stack_8c}{
\section{stack.c File Reference}
\label{stack_8c}\index{stack.c@{stack.c}}
}
Stack manipulation functions. 

{\tt \#include \char`\"{}XLX/stack.h\char`\"{}}\par
{\tt \#include $<$stdlib.h$>$}\par
{\tt \#include $<$string.h$>$}\par
{\tt \#include $<$stdio.h$>$}\par


Include dependency graph for stack.c:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=101pt]{stack_8c__incl}
\end{center}
\end{figure}
\subsection*{Functions}
\begin{CompactItemize}
\item 
unsigned \hyperlink{stack_8c_a0}{XLX\_\-init\-Stack} (\hyperlink{structXLX__stack}{XLX\_\-stack} $\ast$this, unsigned limit)
\begin{CompactList}\small\item\em Initialise a stack by allocating memory to hold the contents and setting limit and used. \item\end{CompactList}\item 
void \hyperlink{stack_8c_a1}{XLX\_\-end\-Stack} (\hyperlink{structXLX__stack}{XLX\_\-stack} $\ast$this)
\begin{CompactList}\small\item\em Free the memory allocated to the stack. \item\end{CompactList}\item 
void \hyperlink{stack_8c_a2}{XLX\_\-destroy\-Stack} (\hyperlink{structXLX__stack}{XLX\_\-stack} $\ast$this, \hyperlink{stack_8h_a0}{XLX\_\-p\-Delete} d\-Fn)
\begin{CompactList}\small\item\em Free the memory allocated to the stack. \item\end{CompactList}\item 
unsigned \hyperlink{stack_8c_a3}{XLX\_\-push} (\hyperlink{structXLX__stack}{XLX\_\-stack} $\ast$this, void $\ast$ptr)
\begin{CompactList}\small\item\em Put a new item on the top of the stack and increment the counter, doubling the size of the stack if the stack is already full. \item\end{CompactList}\item 
void $\ast$ \hyperlink{stack_8c_a4}{XLX\_\-pop} (\hyperlink{structXLX__stack}{XLX\_\-stack} $\ast$this)
\begin{CompactList}\small\item\em Remove and return the top item on the stack. \item\end{CompactList}\item 
void $\ast$ \hyperlink{stack_8c_a5}{XLX\_\-peek} (\hyperlink{structXLX__stack}{XLX\_\-stack} $\ast$this)
\begin{CompactList}\small\item\em Look at the item on the top of the stack without removing it. \item\end{CompactList}\item 
void \hyperlink{stack_8c_a6}{XLX\_\-dump} (\hyperlink{structXLX__stack}{XLX\_\-stack} $\ast$this)
\begin{CompactList}\small\item\em Print out the stack information. \item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Stack manipulation functions. 

\begin{Desc}
\item[Author:]James Swain -- \href{mailto:jswain@slac.stanford.edu}{\tt jswain@slac.stanford.edu}\end{Desc}
history : 12 Nov 2004 : Added history block 15 Nov 2005 : Removed all references to MSG or PBS

\subsection{Function Documentation}
\hypertarget{stack_8c_a2}{
\index{stack.c@{stack.c}!XLX_destroyStack@{XLX\_\-destroyStack}}
\index{XLX_destroyStack@{XLX\_\-destroyStack}!stack.c@{stack.c}}
\subsubsection[XLX\_\-destroyStack]{\setlength{\rightskip}{0pt plus 5cm}void XLX\_\-destroy\-Stack (\hyperlink{structXLX__stack}{XLX\_\-stack} $\ast$ {\em this}, \hyperlink{stack_8h_a0}{XLX\_\-p\-Delete} {\em d\-Fn})}}
\label{stack_8c_a2}


Free the memory allocated to the stack. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em this}]Stack to end \item[{\em d\-Fn}]Function to call to delete objects on the stack\end{description}
\end{Desc}
\hypertarget{stack_8c_a6}{
\index{stack.c@{stack.c}!XLX_dump@{XLX\_\-dump}}
\index{XLX_dump@{XLX\_\-dump}!stack.c@{stack.c}}
\subsubsection[XLX\_\-dump]{\setlength{\rightskip}{0pt plus 5cm}void XLX\_\-dump (\hyperlink{structXLX__stack}{XLX\_\-stack} $\ast$ {\em this})}}
\label{stack_8c_a6}


Print out the stack information. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em this}]Stack to dump\end{description}
\end{Desc}
\hypertarget{stack_8c_a1}{
\index{stack.c@{stack.c}!XLX_endStack@{XLX\_\-endStack}}
\index{XLX_endStack@{XLX\_\-endStack}!stack.c@{stack.c}}
\subsubsection[XLX\_\-endStack]{\setlength{\rightskip}{0pt plus 5cm}void XLX\_\-end\-Stack (\hyperlink{structXLX__stack}{XLX\_\-stack} $\ast$ {\em this})}}
\label{stack_8c_a1}


Free the memory allocated to the stack. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em this}]Stack to end\end{description}
\end{Desc}
\hypertarget{stack_8c_a0}{
\index{stack.c@{stack.c}!XLX_initStack@{XLX\_\-initStack}}
\index{XLX_initStack@{XLX\_\-initStack}!stack.c@{stack.c}}
\subsubsection[XLX\_\-initStack]{\setlength{\rightskip}{0pt plus 5cm}unsigned XLX\_\-init\-Stack (\hyperlink{structXLX__stack}{XLX\_\-stack} $\ast$ {\em this}, unsigned {\em limit})}}
\label{stack_8c_a0}


Initialise a stack by allocating memory to hold the contents and setting limit and used. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em this}]Stack to initialise \item[{\em limit}]Size of the stack \end{description}
\end{Desc}
\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em 0}]If the stack was successfully initialised \item[{\em -1}]If there was an error allocating memory for the stack\end{description}
\end{Desc}
\hypertarget{stack_8c_a5}{
\index{stack.c@{stack.c}!XLX_peek@{XLX\_\-peek}}
\index{XLX_peek@{XLX\_\-peek}!stack.c@{stack.c}}
\subsubsection[XLX\_\-peek]{\setlength{\rightskip}{0pt plus 5cm}void $\ast$ XLX\_\-peek (\hyperlink{structXLX__stack}{XLX\_\-stack} $\ast$ {\em this})}}
\label{stack_8c_a5}


Look at the item on the top of the stack without removing it. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em this}]Stack to peek at \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Item on the top of the stack\end{Desc}
\hypertarget{stack_8c_a4}{
\index{stack.c@{stack.c}!XLX_pop@{XLX\_\-pop}}
\index{XLX_pop@{XLX\_\-pop}!stack.c@{stack.c}}
\subsubsection[XLX\_\-pop]{\setlength{\rightskip}{0pt plus 5cm}void $\ast$ XLX\_\-pop (\hyperlink{structXLX__stack}{XLX\_\-stack} $\ast$ {\em this})}}
\label{stack_8c_a4}


Remove and return the top item on the stack. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em this}]Stack to pop item off \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]Item popped off the top of the stack\end{Desc}
\hypertarget{stack_8c_a3}{
\index{stack.c@{stack.c}!XLX_push@{XLX\_\-push}}
\index{XLX_push@{XLX\_\-push}!stack.c@{stack.c}}
\subsubsection[XLX\_\-push]{\setlength{\rightskip}{0pt plus 5cm}unsigned XLX\_\-push (\hyperlink{structXLX__stack}{XLX\_\-stack} $\ast$ {\em this}, void $\ast$ {\em ptr})}}
\label{stack_8c_a3}


Put a new item on the top of the stack and increment the counter, doubling the size of the stack if the stack is already full. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em this}]Stack to push {\em ptr\/} onto \item[{\em ptr}]Pointer to push onto stack \end{description}
\end{Desc}
\begin{Desc}
\item[Return values:]
\begin{description}
\item[{\em 0}]If the item is added successfully \item[{\em -1}]If the stack needs to be extended to accomodate the new item and the memory allocation failed\end{description}
\end{Desc}
