\hypertarget{stack_8h}{
\section{stack.h File Reference}
\label{stack_8h}\index{stack.h@{stack.h}}
}
Definition of stack structure and declaration of associated functions. 



This graph shows which files directly or indirectly include this file:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=227pt]{stack_8h__dep__incl}
\end{center}
\end{figure}
\subsection*{Data Structures}
\begin{CompactItemize}
\item 
struct \hyperlink{structXLX__stack}{XLX\_\-stack}
\begin{CompactList}\small\item\em Typedef for a stack structure. \item\end{CompactList}\end{CompactItemize}
\subsection*{Typedefs}
\begin{CompactItemize}
\item 
\hypertarget{stack_8h_a0}{
typedef void($\ast$ \hyperlink{stack_8h_a0}{XLX\_\-p\-Delete} )(void $\ast$)}
\label{stack_8h_a0}

\begin{CompactList}\small\item\em Function to use to destroy elements on the stack. \item\end{CompactList}\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
unsigned \hyperlink{stack_8h_a1}{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_8h_a2}{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_8h_a3}{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_8h_a4}{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_8h_a5}{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_8h_a6}{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_8h_a7}{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}
Definition of stack structure and declaration of associated 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

\subsection{Function Documentation}
\hypertarget{stack_8h_a3}{
\index{stack.h@{stack.h}!XLX_destroyStack@{XLX\_\-destroyStack}}
\index{XLX_destroyStack@{XLX\_\-destroyStack}!stack.h@{stack.h}}
\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_8h_a3}


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_8h_a7}{
\index{stack.h@{stack.h}!XLX_dump@{XLX\_\-dump}}
\index{XLX_dump@{XLX\_\-dump}!stack.h@{stack.h}}
\subsubsection[XLX\_\-dump]{\setlength{\rightskip}{0pt plus 5cm}void XLX\_\-dump (\hyperlink{structXLX__stack}{XLX\_\-stack} $\ast$ {\em this})}}
\label{stack_8h_a7}


Print out the stack information. 

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


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_8h_a1}{
\index{stack.h@{stack.h}!XLX_initStack@{XLX\_\-initStack}}
\index{XLX_initStack@{XLX\_\-initStack}!stack.h@{stack.h}}
\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_8h_a1}


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_8h_a6}{
\index{stack.h@{stack.h}!XLX_peek@{XLX\_\-peek}}
\index{XLX_peek@{XLX\_\-peek}!stack.h@{stack.h}}
\subsubsection[XLX\_\-peek]{\setlength{\rightskip}{0pt plus 5cm}void$\ast$ XLX\_\-peek (\hyperlink{structXLX__stack}{XLX\_\-stack} $\ast$ {\em this})}}
\label{stack_8h_a6}


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_8h_a5}{
\index{stack.h@{stack.h}!XLX_pop@{XLX\_\-pop}}
\index{XLX_pop@{XLX\_\-pop}!stack.h@{stack.h}}
\subsubsection[XLX\_\-pop]{\setlength{\rightskip}{0pt plus 5cm}void$\ast$ XLX\_\-pop (\hyperlink{structXLX__stack}{XLX\_\-stack} $\ast$ {\em this})}}
\label{stack_8h_a5}


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_8h_a4}{
\index{stack.h@{stack.h}!XLX_push@{XLX\_\-push}}
\index{XLX_push@{XLX\_\-push}!stack.h@{stack.h}}
\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_8h_a4}


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}
