\doxysection{listelem\+\_\+alloc\+\_\+s Struct Reference}
\label{structlistelem__alloc__s}\index{listelem\_alloc\_s@{listelem\_alloc\_s}}


Fast linked list allocator.  


\doxysubsubsection*{Data Fields}
\begin{DoxyCompactItemize}
\item 
char $\ast$$\ast$ \textbf{ freelist}
\begin{DoxyCompactList}\small\item\em ptr to first element in freelist \end{DoxyCompactList}\item 
\textbf{ glist\+\_\+t} \textbf{ blocks}
\begin{DoxyCompactList}\small\item\em Linked list of blocks allocated. \end{DoxyCompactList}\item 
\textbf{ glist\+\_\+t} \textbf{ blocksize}
\begin{DoxyCompactList}\small\item\em Number of elements in each block. \end{DoxyCompactList}\item 
size\+\_\+t \textbf{ elemsize}
\begin{DoxyCompactList}\small\item\em Number of (char $\ast$) in element. \end{DoxyCompactList}\item 
size\+\_\+t \textbf{ blk\+\_\+alloc}
\begin{DoxyCompactList}\small\item\em Number of alloc operations before increasing blocksize. \end{DoxyCompactList}\item 
size\+\_\+t \textbf{ n\+\_\+blocks}
\item 
size\+\_\+t \textbf{ n\+\_\+alloc}
\item 
size\+\_\+t \textbf{ n\+\_\+freed}
\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Fast linked list allocator. 

We keep a separate linked list for each element-\/size. Element-\/size must be a multiple of pointer-\/size.

Initially a block of empty elements is allocated, where the first machine word in each element points to the next available element. To allocate, we use this pointer to move the freelist to the next element, then return the current element.

The last element in the list starts with a NULL pointer, which is used as a signal to allocate a new block of elements.

In order to be able to actually release the memory allocated, we have to add a linked list of block pointers. This shouldn\textquotesingle{}t create much overhead since we never access it except when freeing the allocator. 

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



\doxysubsection{Field Documentation}
\label{structlistelem__alloc__s_ab96fd1e097105a34d6ae2e79ae8e2520} 
\index{listelem\_alloc\_s@{listelem\_alloc\_s}!blk\_alloc@{blk\_alloc}}
\index{blk\_alloc@{blk\_alloc}!listelem\_alloc\_s@{listelem\_alloc\_s}}
\doxysubsubsection{blk\_alloc}
{\footnotesize\ttfamily size\+\_\+t listelem\+\_\+alloc\+\_\+s\+::blk\+\_\+alloc}



Number of alloc operations before increasing blocksize. 



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



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

\label{structlistelem__alloc__s_a1216578b1d5416dc0a03c802cfa1def9} 
\index{listelem\_alloc\_s@{listelem\_alloc\_s}!blocks@{blocks}}
\index{blocks@{blocks}!listelem\_alloc\_s@{listelem\_alloc\_s}}
\doxysubsubsection{blocks}
{\footnotesize\ttfamily \textbf{ glist\+\_\+t} listelem\+\_\+alloc\+\_\+s\+::blocks}



Linked list of blocks allocated. 



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



Referenced by \textbf{ listelem\+\_\+alloc\+\_\+free()}, \textbf{ listelem\+\_\+alloc\+\_\+init()}, \textbf{ listelem\+\_\+get\+\_\+item()}, and \textbf{ listelem\+\_\+stats()}.

\label{structlistelem__alloc__s_ada7b3fcd2f878e67e07e4bb185bb3015} 
\index{listelem\_alloc\_s@{listelem\_alloc\_s}!blocksize@{blocksize}}
\index{blocksize@{blocksize}!listelem\_alloc\_s@{listelem\_alloc\_s}}
\doxysubsubsection{blocksize}
{\footnotesize\ttfamily \textbf{ glist\+\_\+t} listelem\+\_\+alloc\+\_\+s\+::blocksize}



Number of elements in each block. 



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



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

\label{structlistelem__alloc__s_a9e27c7163c45a43f8dfd667cbc014f49} 
\index{listelem\_alloc\_s@{listelem\_alloc\_s}!elemsize@{elemsize}}
\index{elemsize@{elemsize}!listelem\_alloc\_s@{listelem\_alloc\_s}}
\doxysubsubsection{elemsize}
{\footnotesize\ttfamily size\+\_\+t listelem\+\_\+alloc\+\_\+s\+::elemsize}



Number of (char $\ast$) in element. 



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



Referenced by \textbf{ listelem\+\_\+alloc\+\_\+init()}, \textbf{ listelem\+\_\+get\+\_\+item()}, and \textbf{ listelem\+\_\+stats()}.

\label{structlistelem__alloc__s_a2c3be8623c5bb2d4afb3ad888790a4eb} 
\index{listelem\_alloc\_s@{listelem\_alloc\_s}!freelist@{freelist}}
\index{freelist@{freelist}!listelem\_alloc\_s@{listelem\_alloc\_s}}
\doxysubsubsection{freelist}
{\footnotesize\ttfamily char$\ast$$\ast$ listelem\+\_\+alloc\+\_\+s\+::freelist}



ptr to first element in freelist 



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



Referenced by \textbf{ \+\_\+\+\_\+listelem\+\_\+free\+\_\+\+\_\+()}, \textbf{ listelem\+\_\+alloc\+\_\+init()}, and \textbf{ listelem\+\_\+stats()}.

\label{structlistelem__alloc__s_a2a2fa0a7a1e03d6aee2f685dbc1db774} 
\index{listelem\_alloc\_s@{listelem\_alloc\_s}!n\_alloc@{n\_alloc}}
\index{n\_alloc@{n\_alloc}!listelem\_alloc\_s@{listelem\_alloc\_s}}
\doxysubsubsection{n\_alloc}
{\footnotesize\ttfamily size\+\_\+t listelem\+\_\+alloc\+\_\+s\+::n\+\_\+alloc}



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

\label{structlistelem__alloc__s_a90c7d399a72d00cdb476bd5f518b4711} 
\index{listelem\_alloc\_s@{listelem\_alloc\_s}!n\_blocks@{n\_blocks}}
\index{n\_blocks@{n\_blocks}!listelem\_alloc\_s@{listelem\_alloc\_s}}
\doxysubsubsection{n\_blocks}
{\footnotesize\ttfamily size\+\_\+t listelem\+\_\+alloc\+\_\+s\+::n\+\_\+blocks}



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

\label{structlistelem__alloc__s_adde313f665b6f2be9ea22f4d209e576d} 
\index{listelem\_alloc\_s@{listelem\_alloc\_s}!n\_freed@{n\_freed}}
\index{n\_freed@{n\_freed}!listelem\_alloc\_s@{listelem\_alloc\_s}}
\doxysubsubsection{n\_freed}
{\footnotesize\ttfamily size\+\_\+t listelem\+\_\+alloc\+\_\+s\+::n\+\_\+freed}



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



The documentation for this struct was generated from the following file\+:\begin{DoxyCompactItemize}
\item 
src/libsphinxbase/util/listelem\+\_\+alloc.\+c\end{DoxyCompactItemize}
