\hypertarget{BFA_8h}{
\section{BFA.h File Reference}
\label{BFA_8h}\index{BFA.h@{BFA.h}}
}
Balloon Flight Memory Allocator, Interface. 


\subsection*{Typedefs}
\begin{CompactItemize}
\item 
\hypertarget{BFA_8h_a0}{
\index{BFA_acb@{BFA\_\-acb}!BFA.h@{BFA.h}}\index{BFA.h@{BFA.h}!BFA_acb@{BFA\_\-acb}}
typedef \hyperlink{struct__BFA__acb}{\_\-BFA\_\-acb} \hyperlink{BFA_8h_a0}{BFA\_\-acb}}
\label{BFA_8h_a0}

\begin{CompactList}\small\item\em Typedef for struct \hyperlink{struct__BFA__acb}{\_\-BFA\_\-acb}.\item\end{CompactList}\end{CompactItemize}
\subsection*{Functions}
\begin{CompactItemize}
\item 
int \hyperlink{BFA_8h_a1}{BFA\_\-copy} (\hyperlink{BFA_8h_a0}{BFA\_\-acb} $\ast$acb, void $\ast$eop)
\begin{CompactList}\small\item\em Copies any piece of memory that spills into the overflow area back to the top of the ring buffer pool.\item\end{CompactList}\item 
\hyperlink{struct__BFU__fileDsc}{\_\-BFU\_\-file\-Dsc} $\ast$ \hyperlink{BFA_8h_a2}{BFA\_\-get} (\hyperlink{BFA_8h_a0}{BFA\_\-acb} $\ast$acb, int nevts, int nsums, int nbytes)
\begin{CompactList}\small\item\em Allocates the requested number of bytes for the requested number of events.\item\end{CompactList}\item 
\hyperlink{struct__BFA__acb}{\_\-BFA\_\-acb} $\ast$ \hyperlink{BFA_8h_a3}{BFA\_\-open} (int dsc\_\-pool\_\-size, int dsc\_\-max\_\-alloc\_\-size, int evt\_\-pool\_\-size, int evt\_\-max\_\-alloc\_\-size)
\begin{CompactList}\small\item\em Allocates the control structure and memory for the BFA allocator.\item\end{CompactList}\item 
\_\-RNG\_\-rcb $\ast$ \hyperlink{BFA_8h_a4}{BFA\_\-evt\-Rcb\-Get} (const \hyperlink{BFA_8h_a0}{BFA\_\-acb} $\ast$acb)
\begin{CompactList}\small\item\em Simple query routine to get the control structure of the event descriptors ring buffer that BFA is managing.\item\end{CompactList}\item 
\_\-RNG\_\-rcb $\ast$ \hyperlink{BFA_8h_a5}{BFA\_\-dsc\-Rcb\-Get} (const \hyperlink{BFA_8h_a0}{BFA\_\-acb} $\ast$acb)
\begin{CompactList}\small\item\em Simple query routine to get the control structure of the event ring buffer that BFA is managing.\item\end{CompactList}\item 
int \hyperlink{BFA_8h_a6}{BFA\_\-dsc\-Rcb\-Reset} (\hyperlink{BFA_8h_a0}{BFA\_\-acb} $\ast$acb)
\begin{CompactList}\small\item\em Resets the event descriptor ring buffer to its initial state.\item\end{CompactList}\item 
int \hyperlink{BFA_8h_a7}{BFA\_\-evt\-Rcb\-Reset} (\hyperlink{BFA_8h_a0}{BFA\_\-acb} $\ast$acb)
\begin{CompactList}\small\item\em Resets the event ring buffer to its initial state.\item\end{CompactList}\end{CompactItemize}


\subsection{Detailed Description}
Balloon Flight Memory Allocator, Interface.



\begin{Desc}
\item[Author: ]\par
JJRussell - \href{mailto:russell@slac.stanford.edu}{\tt russell@slac.stanford.edu}\end{Desc}
Manages the input memory, ie where the events are read into.



\subsection{Function Documentation}
\hypertarget{BFA_8h_a1}{
\index{BFA.h@{BFA.h}!BFA_copy@{BFA\_\-copy}}
\index{BFA_copy@{BFA\_\-copy}!BFA.h@{BFA.h}}
\subsubsection[BFA\_\-copy]{\setlength{\rightskip}{0pt plus 5cm}int BFA\_\-copy (\hyperlink{BFA_8h_a0}{BFA\_\-acb} $\ast$ {\em acb}, void $\ast$ {\em eop})}}
\label{BFA_8h_a1}


Copies any piece of memory that spills into the overflow area back to the top of the ring buffer pool.

\begin{Desc}
\item[Parameters: ]\par
\begin{description}
\item[{\em 
scb}]Memory allocator's control block. \item[{\em 
eop}]Pointer to the end of the packet. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns: ]\par
If positive or 0, the number of bytes copied. If negative an error.\end{Desc}
Checks to see if any piece of the packet defined by 'eop' (end of packet address) lives in the overflow area. If it does, then a piece of memory is allocated at (it must be at the top of the buffer) and the piece in the overflow area is copied into that area. Note that by definition a data packet always starts within the the ring buffer proper.

The eop pointer must also be, be definition, the next allocation pointer. \hypertarget{BFA_8h_a5}{
\index{BFA.h@{BFA.h}!BFA_dscRcbGet@{BFA\_\-dscRcbGet}}
\index{BFA_dscRcbGet@{BFA\_\-dscRcbGet}!BFA.h@{BFA.h}}
\subsubsection[BFA\_\-dscRcbGet]{\setlength{\rightskip}{0pt plus 5cm}struct \_\-RNG\_\-rcb $\ast$ BFA\_\-dsc\-Rcb\-Get (const \hyperlink{BFA_8h_a0}{BFA\_\-acb} $\ast$ {\em acb})}}
\label{BFA_8h_a5}


Simple query routine to get the control structure of the event ring buffer that BFA is managing.

\begin{Desc}
\item[Parameters: ]\par
\begin{description}
\item[{\em 
acb}]Memory allocator's control block handle. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns: ]\par
The Ring Buffer Control Structure handle. \end{Desc}
\hypertarget{BFA_8h_a6}{
\index{BFA.h@{BFA.h}!BFA_dscRcbReset@{BFA\_\-dscRcbReset}}
\index{BFA_dscRcbReset@{BFA\_\-dscRcbReset}!BFA.h@{BFA.h}}
\subsubsection[BFA\_\-dscRcbReset]{\setlength{\rightskip}{0pt plus 5cm}int BFA\_\-dsc\-Rcb\-Reset (\hyperlink{BFA_8h_a0}{BFA\_\-acb} $\ast$ {\em acb})}}
\label{BFA_8h_a6}


Resets the event descriptor ring buffer to its initial state.

\begin{Desc}
\item[Parameters: ]\par
\begin{description}
\item[{\em 
acb}]Memory allocator's control block handle. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns: ]\par
Status. Failure indicates the ring buffer was not empty.\end{Desc}
The ring buffer must be empty for this routine to be successful. \hypertarget{BFA_8h_a4}{
\index{BFA.h@{BFA.h}!BFA_evtRcbGet@{BFA\_\-evtRcbGet}}
\index{BFA_evtRcbGet@{BFA\_\-evtRcbGet}!BFA.h@{BFA.h}}
\subsubsection[BFA\_\-evtRcbGet]{\setlength{\rightskip}{0pt plus 5cm}struct \_\-RNG\_\-rcb $\ast$ BFA\_\-evt\-Rcb\-Get (const \hyperlink{BFA_8h_a0}{BFA\_\-acb} $\ast$ {\em acb})}}
\label{BFA_8h_a4}


Simple query routine to get the control structure of the event descriptors ring buffer that BFA is managing.

\begin{Desc}
\item[Parameters: ]\par
\begin{description}
\item[{\em 
acb}]Memory allocator's control block handle. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns: ]\par
The Ring Buffer Control Structure handle. \end{Desc}
\hypertarget{BFA_8h_a7}{
\index{BFA.h@{BFA.h}!BFA_evtRcbReset@{BFA\_\-evtRcbReset}}
\index{BFA_evtRcbReset@{BFA\_\-evtRcbReset}!BFA.h@{BFA.h}}
\subsubsection[BFA\_\-evtRcbReset]{\setlength{\rightskip}{0pt plus 5cm}int BFA\_\-evt\-Rcb\-Reset (\hyperlink{BFA_8h_a0}{BFA\_\-acb} $\ast$ {\em acb})}}
\label{BFA_8h_a7}


Resets the event ring buffer to its initial state.

\begin{Desc}
\item[Parameters: ]\par
\begin{description}
\item[{\em 
acb}]Memory allocator's control block handle. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns: ]\par
Status. Failure indicates the ring buffer was not empty.\end{Desc}
The ring buffer must be empty for this routine to be successful. \hypertarget{BFA_8h_a2}{
\index{BFA.h@{BFA.h}!BFA_get@{BFA\_\-get}}
\index{BFA_get@{BFA\_\-get}!BFA.h@{BFA.h}}
\subsubsection[BFA\_\-get]{\setlength{\rightskip}{0pt plus 5cm}struct \hyperlink{struct__BFU__fileDsc}{\_\-BFU\_\-file\-Dsc} $\ast$ BFA\_\-get (\hyperlink{BFA_8h_a0}{BFA\_\-acb} $\ast$ {\em acb}, int {\em nevts}, int {\em nsums}, int {\em nbytes})}}
\label{BFA_8h_a2}


Allocates the requested number of bytes for the requested number of events.

\begin{Desc}
\item[Parameters: ]\par
\begin{description}
\item[{\em 
acb}]Memory allocator control block handle. \item[{\em 
nevts}]The number of events that need to be described. \end{description}
\end{Desc}
\begin{Desc}
\item[ma nsums   The number of summary records.]\par
 \end{Desc}
\begin{Desc}
\item[Parameters: ]\par
\begin{description}
\item[{\em 
nbytes}]The number of bytes to allocate \end{description}
\end{Desc}
\begin{Desc}
\item[Returns: ]\par
If successful, a pointer to the allocated event descriptor, else NULL. \end{Desc}
\hypertarget{BFA_8h_a3}{
\index{BFA.h@{BFA.h}!BFA_open@{BFA\_\-open}}
\index{BFA_open@{BFA\_\-open}!BFA.h@{BFA.h}}
\subsubsection[BFA\_\-open]{\setlength{\rightskip}{0pt plus 5cm}struct \hyperlink{struct__BFA__acb}{\_\-BFA\_\-acb} $\ast$ BFA\_\-open (int {\em dsc\_\-pool\_\-size}, int {\em dsc\_\-max\_\-alloc\_\-size}, int {\em evt\_\-pool\_\-size}, int {\em evt\_\-max\_\-alloc\_\-size})}}
\label{BFA_8h_a3}


Allocates the control structure and memory for the BFA allocator.

\begin{Desc}
\item[Parameters: ]\par
\begin{description}
\item[{\em 
dsc\_\-pool\_\-size}]The event descriptor pool size. \item[{\em 
dsc\_\-max\_\-alloc\_\-size}]The size, in bytes, of the maximum descriptor. \item[{\em 
evt\_\-pool\_\-size}]The event pool size, in bytes.  \item[{\em 
evt\_\-max\_\-alloc\_\-size}]The size, in bytes, of the maximum event allocation. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns: ]\par
If successful, a handle to the pool, else NULL.\end{Desc}
Allocates and initializes a memory pool for BFA's use. Two pools are allocated, one to allocate memory for the event data and one for allocation of event descriptors

Each memory pool is divided into three pieces. The total size is set by the 'pool\_\-size'. An underflow area is allocated at the top of the pool and an overflow area is allocated at the bottom. These areas allow the internal memory manager to satisfy requests up to 'max\_\-alloc\_\-size' as contigious chunks of memory that also obey blocking (chunking) constraints. 