\doxysection{include/sphinxbase/listelem\+\_\+alloc.h File Reference}
\label{listelem__alloc_8h}\index{include/sphinxbase/listelem\_alloc.h@{include/sphinxbase/listelem\_alloc.h}}


Fast memory allocator for uniformly sized objects.  


{\ttfamily \#include $<$stdlib.\+h$>$}\newline
{\ttfamily \#include $<$sphinxbase/sphinxbase\+\_\+export.\+h$>$}\newline
{\ttfamily \#include $<$sphinxbase/prim\+\_\+type.\+h$>$}\newline
\doxysubsubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \textbf{ listelem\+\_\+malloc}(le)~\+\_\+\+\_\+listelem\+\_\+malloc\+\_\+\+\_\+((le),\+\_\+\+\_\+\+FILE\+\_\+\+\_\+,\+\_\+\+\_\+\+LINE\+\_\+\+\_\+)
\begin{DoxyCompactList}\small\item\em Allocate a list element and return pointer to it. \end{DoxyCompactList}\item 
\#define \textbf{ listelem\+\_\+malloc\+\_\+id}(le,  oid)~\+\_\+\+\_\+listelem\+\_\+malloc\+\_\+id\+\_\+\+\_\+((le),\+\_\+\+\_\+\+FILE\+\_\+\+\_\+,\+\_\+\+\_\+\+LINE\+\_\+\+\_\+,(oid))
\begin{DoxyCompactList}\small\item\em Allocate a list element, returning a unique identifier. \end{DoxyCompactList}\item 
\#define \textbf{ listelem\+\_\+free}(le,  el)~\textbf{ \+\_\+\+\_\+listelem\+\_\+free\+\_\+\+\_\+}((le),(el),\+\_\+\+\_\+\+FILE\+\_\+\+\_\+,\+\_\+\+\_\+\+LINE\+\_\+\+\_\+)
\begin{DoxyCompactList}\small\item\em Macro of {\bfseries{listelem\+\_\+free}} \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsubsection*{Typedefs}
\begin{DoxyCompactItemize}
\item 
typedef struct \textbf{ listelem\+\_\+alloc\+\_\+s} \textbf{ listelem\+\_\+alloc\+\_\+t}
\begin{DoxyCompactList}\small\item\em List element allocator object. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
SPHINXBASE\+\_\+\+EXPORT \textbf{ listelem\+\_\+alloc\+\_\+t} $\ast$ \textbf{ listelem\+\_\+alloc\+\_\+init} (size\+\_\+t elemsize)
\begin{DoxyCompactList}\small\item\em Initialize and return a list element allocator. \end{DoxyCompactList}\item 
SPHINXBASE\+\_\+\+EXPORT void \textbf{ listelem\+\_\+alloc\+\_\+free} (\textbf{ listelem\+\_\+alloc\+\_\+t} $\ast$le)
\begin{DoxyCompactList}\small\item\em Finalize and release all memory associated with a list element allocator. \end{DoxyCompactList}\item 
SPHINXBASE\+\_\+\+EXPORT void $\ast$ \textbf{ \+\_\+\+\_\+listelem\+\_\+malloc\+\_\+\+\_\+} (\textbf{ listelem\+\_\+alloc\+\_\+t} $\ast$le, char $\ast$file, int line)
\item 
SPHINXBASE\+\_\+\+EXPORT void $\ast$ \textbf{ \+\_\+\+\_\+listelem\+\_\+malloc\+\_\+id\+\_\+\+\_\+} (\textbf{ listelem\+\_\+alloc\+\_\+t} $\ast$le, char $\ast$file, int line, int32 $\ast$out\+\_\+id)
\item 
SPHINXBASE\+\_\+\+EXPORT void $\ast$ \textbf{ listelem\+\_\+get\+\_\+item} (\textbf{ listelem\+\_\+alloc\+\_\+t} $\ast$le, int32 id)
\begin{DoxyCompactList}\small\item\em Retrieve a list element by its identifier. \end{DoxyCompactList}\item 
SPHINXBASE\+\_\+\+EXPORT void \textbf{ \+\_\+\+\_\+listelem\+\_\+free\+\_\+\+\_\+} (\textbf{ listelem\+\_\+alloc\+\_\+t} $\ast$le, void $\ast$elem, char $\ast$file, int line)
\begin{DoxyCompactList}\small\item\em Free list element of given size. \end{DoxyCompactList}\item 
SPHINXBASE\+\_\+\+EXPORT void \textbf{ listelem\+\_\+stats} (\textbf{ listelem\+\_\+alloc\+\_\+t} $\ast$le)
\begin{DoxyCompactList}\small\item\em Print number of allocation, numer of free operation stats. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Fast memory allocator for uniformly sized objects. 

\begin{DoxyAuthor}{Author}
M K Ravishankar {\texttt{ rkm@cs.\+cmu.\+edu}} 
\end{DoxyAuthor}


Definition in file \textbf{ listelem\+\_\+alloc.\+h}.



\doxysubsection{Macro Definition Documentation}
\label{listelem__alloc_8h_a67de661d7ca552347fa6f03005e25d74} 
\index{listelem\_alloc.h@{listelem\_alloc.h}!listelem\_free@{listelem\_free}}
\index{listelem\_free@{listelem\_free}!listelem\_alloc.h@{listelem\_alloc.h}}
\doxysubsubsection{listelem\_free}
{\footnotesize\ttfamily \#define listelem\+\_\+free(\begin{DoxyParamCaption}\item[{}]{le,  }\item[{}]{el }\end{DoxyParamCaption})~\textbf{ \+\_\+\+\_\+listelem\+\_\+free\+\_\+\+\_\+}((le),(el),\+\_\+\+\_\+\+FILE\+\_\+\+\_\+,\+\_\+\+\_\+\+LINE\+\_\+\+\_\+)}



Macro of {\bfseries{listelem\+\_\+free}} 



Definition at line \textbf{ 112} of file \textbf{ listelem\+\_\+alloc.\+h}.

\label{listelem__alloc_8h_ad0c40e65d9cca0d7ec08fcf416b09af2} 
\index{listelem\_alloc.h@{listelem\_alloc.h}!listelem\_malloc@{listelem\_malloc}}
\index{listelem\_malloc@{listelem\_malloc}!listelem\_alloc.h@{listelem\_alloc.h}}
\doxysubsubsection{listelem\_malloc}
{\footnotesize\ttfamily \#define listelem\+\_\+malloc(\begin{DoxyParamCaption}\item[{}]{le }\end{DoxyParamCaption})~\+\_\+\+\_\+listelem\+\_\+malloc\+\_\+\+\_\+((le),\+\_\+\+\_\+\+FILE\+\_\+\+\_\+,\+\_\+\+\_\+\+LINE\+\_\+\+\_\+)}



Allocate a list element and return pointer to it. 



Definition at line \textbf{ 86} of file \textbf{ listelem\+\_\+alloc.\+h}.

\label{listelem__alloc_8h_aa9bbb7161aceacdba49b41b189554507} 
\index{listelem\_alloc.h@{listelem\_alloc.h}!listelem\_malloc\_id@{listelem\_malloc\_id}}
\index{listelem\_malloc\_id@{listelem\_malloc\_id}!listelem\_alloc.h@{listelem\_alloc.h}}
\doxysubsubsection{listelem\_malloc\_id}
{\footnotesize\ttfamily \#define listelem\+\_\+malloc\+\_\+id(\begin{DoxyParamCaption}\item[{}]{le,  }\item[{}]{oid }\end{DoxyParamCaption})~\+\_\+\+\_\+listelem\+\_\+malloc\+\_\+id\+\_\+\+\_\+((le),\+\_\+\+\_\+\+FILE\+\_\+\+\_\+,\+\_\+\+\_\+\+LINE\+\_\+\+\_\+,(oid))}



Allocate a list element, returning a unique identifier. 



Definition at line \textbf{ 95} of file \textbf{ listelem\+\_\+alloc.\+h}.



\doxysubsection{Typedef Documentation}
\label{listelem__alloc_8h_a3fd3950d7834feaa2bbdf84afb98ce32} 
\index{listelem\_alloc.h@{listelem\_alloc.h}!listelem\_alloc\_t@{listelem\_alloc\_t}}
\index{listelem\_alloc\_t@{listelem\_alloc\_t}!listelem\_alloc.h@{listelem\_alloc.h}}
\doxysubsubsection{listelem\_alloc\_t}
{\footnotesize\ttfamily typedef struct \textbf{ listelem\+\_\+alloc\+\_\+s} \textbf{ listelem\+\_\+alloc\+\_\+t}}



List element allocator object. 



Definition at line \textbf{ 65} of file \textbf{ listelem\+\_\+alloc.\+h}.



\doxysubsection{Function Documentation}
\label{listelem__alloc_8h_ab83a7a6fd086c14140ad2c8c4162709b} 
\index{listelem\_alloc.h@{listelem\_alloc.h}!\_\_listelem\_free\_\_@{\_\_listelem\_free\_\_}}
\index{\_\_listelem\_free\_\_@{\_\_listelem\_free\_\_}!listelem\_alloc.h@{listelem\_alloc.h}}
\doxysubsubsection{\_\_listelem\_free\_\_()}
{\footnotesize\ttfamily SPHINXBASE\+\_\+\+EXPORT void \+\_\+\+\_\+listelem\+\_\+free\+\_\+\+\_\+ (\begin{DoxyParamCaption}\item[{\textbf{ listelem\+\_\+alloc\+\_\+t} $\ast$}]{le,  }\item[{void $\ast$}]{elem,  }\item[{char $\ast$}]{file,  }\item[{int}]{line }\end{DoxyParamCaption})}



Free list element of given size. 



Definition at line \textbf{ 257} of file \textbf{ listelem\+\_\+alloc.\+c}.



References \textbf{ \+\_\+\+\_\+listelem\+\_\+free\+\_\+\+\_\+()}, and \textbf{ listelem\+\_\+alloc\+\_\+s\+::freelist}.



Referenced by \textbf{ \+\_\+\+\_\+listelem\+\_\+free\+\_\+\+\_\+()}.

\label{listelem__alloc_8h_a761a602dcfe8f94ea429863b62ab583a} 
\index{listelem\_alloc.h@{listelem\_alloc.h}!\_\_listelem\_malloc\_\_@{\_\_listelem\_malloc\_\_}}
\index{\_\_listelem\_malloc\_\_@{\_\_listelem\_malloc\_\_}!listelem\_alloc.h@{listelem\_alloc.h}}
\doxysubsubsection{\_\_listelem\_malloc\_\_()}
{\footnotesize\ttfamily SPHINXBASE\+\_\+\+EXPORT void $\ast$ \+\_\+\+\_\+listelem\+\_\+malloc\+\_\+\+\_\+ (\begin{DoxyParamCaption}\item[{\textbf{ listelem\+\_\+alloc\+\_\+t} $\ast$}]{le,  }\item[{char $\ast$}]{file,  }\item[{int}]{line }\end{DoxyParamCaption})}



Definition at line \textbf{ 173} of file \textbf{ listelem\+\_\+alloc.\+c}.

\label{listelem__alloc_8h_af23770458948221e27cbd00c679e9b4b} 
\index{listelem\_alloc.h@{listelem\_alloc.h}!\_\_listelem\_malloc\_id\_\_@{\_\_listelem\_malloc\_id\_\_}}
\index{\_\_listelem\_malloc\_id\_\_@{\_\_listelem\_malloc\_id\_\_}!listelem\_alloc.h@{listelem\_alloc.h}}
\doxysubsubsection{\_\_listelem\_malloc\_id\_\_()}
{\footnotesize\ttfamily SPHINXBASE\+\_\+\+EXPORT void $\ast$ \+\_\+\+\_\+listelem\+\_\+malloc\+\_\+id\+\_\+\+\_\+ (\begin{DoxyParamCaption}\item[{\textbf{ listelem\+\_\+alloc\+\_\+t} $\ast$}]{le,  }\item[{char $\ast$}]{file,  }\item[{int}]{line,  }\item[{int32 $\ast$}]{out\+\_\+id }\end{DoxyParamCaption})}



Definition at line \textbf{ 190} of file \textbf{ listelem\+\_\+alloc.\+c}.

\label{listelem__alloc_8h_a94c02e93a0abaa2bd79636cbac6cced2} 
\index{listelem\_alloc.h@{listelem\_alloc.h}!listelem\_alloc\_free@{listelem\_alloc\_free}}
\index{listelem\_alloc\_free@{listelem\_alloc\_free}!listelem\_alloc.h@{listelem\_alloc.h}}
\doxysubsubsection{listelem\_alloc\_free()}
{\footnotesize\ttfamily SPHINXBASE\+\_\+\+EXPORT void listelem\+\_\+alloc\+\_\+free (\begin{DoxyParamCaption}\item[{\textbf{ listelem\+\_\+alloc\+\_\+t} $\ast$}]{le }\end{DoxyParamCaption})}



Finalize and release all memory associated with a list element allocator. 



Definition at line \textbf{ 121} of file \textbf{ listelem\+\_\+alloc.\+c}.



References \textbf{ listelem\+\_\+alloc\+\_\+s\+::blocks}, \textbf{ listelem\+\_\+alloc\+\_\+s\+::blocksize}, \textbf{ ckd\+\_\+free()}, \textbf{ glist\+\_\+free()}, \textbf{ gnode\+\_\+ptr}, and \textbf{ listelem\+\_\+alloc\+\_\+free()}.



Referenced by \textbf{ listelem\+\_\+alloc\+\_\+free()}.

\label{listelem__alloc_8h_abdd208d7555e2821c4ce626acbb2ab8a} 
\index{listelem\_alloc.h@{listelem\_alloc.h}!listelem\_alloc\_init@{listelem\_alloc\_init}}
\index{listelem\_alloc\_init@{listelem\_alloc\_init}!listelem\_alloc.h@{listelem\_alloc.h}}
\doxysubsubsection{listelem\_alloc\_init()}
{\footnotesize\ttfamily SPHINXBASE\+\_\+\+EXPORT \textbf{ listelem\+\_\+alloc\+\_\+t} $\ast$ listelem\+\_\+alloc\+\_\+init (\begin{DoxyParamCaption}\item[{size\+\_\+t}]{elemsize }\end{DoxyParamCaption})}



Initialize and return a list element allocator. 



Definition at line \textbf{ 87} of file \textbf{ listelem\+\_\+alloc.\+c}.



References \textbf{ listelem\+\_\+alloc\+\_\+s\+::blk\+\_\+alloc}, \textbf{ listelem\+\_\+alloc\+\_\+s\+::blocks}, \textbf{ ckd\+\_\+calloc}, \textbf{ ckd\+\_\+free()}, \textbf{ E\+\_\+\+ERROR}, \textbf{ E\+\_\+\+WARN}, \textbf{ listelem\+\_\+alloc\+\_\+s\+::elemsize}, \textbf{ listelem\+\_\+alloc\+\_\+s\+::freelist}, and \textbf{ listelem\+\_\+alloc\+\_\+init()}.



Referenced by \textbf{ listelem\+\_\+alloc\+\_\+init()}.

\label{listelem__alloc_8h_ab147ffb83040c1bea89bb3a26a9178be} 
\index{listelem\_alloc.h@{listelem\_alloc.h}!listelem\_get\_item@{listelem\_get\_item}}
\index{listelem\_get\_item@{listelem\_get\_item}!listelem\_alloc.h@{listelem\_alloc.h}}
\doxysubsubsection{listelem\_get\_item()}
{\footnotesize\ttfamily SPHINXBASE\+\_\+\+EXPORT void $\ast$ listelem\+\_\+get\+\_\+item (\begin{DoxyParamCaption}\item[{\textbf{ listelem\+\_\+alloc\+\_\+t} $\ast$}]{le,  }\item[{int32}]{id }\end{DoxyParamCaption})}



Retrieve a list element by its identifier. 



Definition at line \textbf{ 233} of file \textbf{ listelem\+\_\+alloc.\+c}.



References \textbf{ listelem\+\_\+alloc\+\_\+s\+::blocks}, \textbf{ E\+\_\+\+ERROR}, \textbf{ listelem\+\_\+alloc\+\_\+s\+::elemsize}, \textbf{ gnode\+\_\+ptr}, and \textbf{ listelem\+\_\+get\+\_\+item()}.



Referenced by \textbf{ listelem\+\_\+get\+\_\+item()}.

\label{listelem__alloc_8h_a838d9361ba76a89a834a7ea6a185b57d} 
\index{listelem\_alloc.h@{listelem\_alloc.h}!listelem\_stats@{listelem\_stats}}
\index{listelem\_stats@{listelem\_stats}!listelem\_alloc.h@{listelem\_alloc.h}}
\doxysubsubsection{listelem\_stats()}
{\footnotesize\ttfamily SPHINXBASE\+\_\+\+EXPORT void listelem\+\_\+stats (\begin{DoxyParamCaption}\item[{\textbf{ listelem\+\_\+alloc\+\_\+t} $\ast$}]{le }\end{DoxyParamCaption})}



Print number of allocation, numer of free operation stats. 



Definition at line \textbf{ 273} of file \textbf{ listelem\+\_\+alloc.\+c}.



References \textbf{ listelem\+\_\+alloc\+\_\+s\+::blocks}, \textbf{ listelem\+\_\+alloc\+\_\+s\+::blocksize}, \textbf{ E\+\_\+\+INFO}, \textbf{ listelem\+\_\+alloc\+\_\+s\+::elemsize}, \textbf{ listelem\+\_\+alloc\+\_\+s\+::freelist}, \textbf{ gnode\+\_\+ptr}, and \textbf{ listelem\+\_\+stats()}.



Referenced by \textbf{ listelem\+\_\+stats()}.

