\doxysection{Section allocation:\+ malloc or mmap }
\hypertarget{group__sectionallocpref}{}\label{group__sectionallocpref}\index{Section allocation: malloc or mmap@{Section allocation: malloc or mmap}}
\doxysubsubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
DW\+\_\+\+API enum \doxymbox{\hyperlink{group__allstructs_ga8e19573b56799157d063d8cc2828f69b}{Dwarf\+\_\+\+Sec\+\_\+\+Alloc\+\_\+\+Pref}} \doxymbox{\hyperlink{group__sectionallocpref_ga38895d41776523190f5c7e2af4f6391c}{dwarf\+\_\+set\+\_\+load\+\_\+preference}} (enum \doxymbox{\hyperlink{group__allstructs_ga8e19573b56799157d063d8cc2828f69b}{Dwarf\+\_\+\+Sec\+\_\+\+Alloc\+\_\+\+Pref}} dw\+\_\+load\+\_\+preference)
\begin{DoxyCompactList}\small\item\em Set/\+\+Retrieve section allocation preference. \end{DoxyCompactList}\item 
DW\+\_\+\+API int \doxymbox{\hyperlink{group__sectionallocpref_ga00887b728c214e4d85d50ac0d0d1f9dd}{dwarf\+\_\+get\+\_\+mmap\+\_\+count}} (\doxymbox{\hyperlink{group__allstructs_gac2ba1e1c1b70a3191506b414195ca807}{Dwarf\+\_\+\+Debug}} dw\+\_\+dbg, \doxymbox{\hyperlink{group__basicdatatypes_ga5de64bb9627534a24dcbccc327916265}{Dwarf\+\_\+\+Unsigned}} \texorpdfstring{$\ast$}{*}dw\+\_\+mmap\+\_\+count, \doxymbox{\hyperlink{group__basicdatatypes_ga5de64bb9627534a24dcbccc327916265}{Dwarf\+\_\+\+Unsigned}} \texorpdfstring{$\ast$}{*}dw\+\_\+mmap\+\_\+size, \doxymbox{\hyperlink{group__basicdatatypes_ga5de64bb9627534a24dcbccc327916265}{Dwarf\+\_\+\+Unsigned}} \texorpdfstring{$\ast$}{*}dw\+\_\+malloc\+\_\+count, \doxymbox{\hyperlink{group__basicdatatypes_ga5de64bb9627534a24dcbccc327916265}{Dwarf\+\_\+\+Unsigned}} \texorpdfstring{$\ast$}{*}dw\+\_\+malloc\+\_\+size)
\begin{DoxyCompactList}\small\item\em Retrieve count of mmap/\+malloc sections. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Functions related to the choice of malloc/\+read or mmap for object section memory allocation.

The default allocation preference is malloc().

The shell environment variable DWARF\+\_\+\+WHICH\+\_\+\+ALLOC is also involved at runtime but it only applies to reading Elf object files.. If the value is \textquotesingle{}malloc\textquotesingle{} then use of read/\+malloc is preferred. If the value is \textquotesingle{}mmap\textquotesingle{} then use of mmap is preferred (Example:\+ \textquotesingle{}export DWARF\+\_\+\+WHICH\+\_\+\+ALLOC=mmap\textquotesingle{}). Otherwise, the environment value is checked and ignored.

If present and valid this environment variable takes precedence over \doxylink{group__sectionallocpref_ga38895d41776523190f5c7e2af4f6391c}{dwarf\+\_\+set\+\_\+load\+\_\+preference()}. 

\label{doc-func-members}
\Hypertarget{group__sectionallocpref_doc-func-members}
\doxysubsection{Function Documentation}
\Hypertarget{group__sectionallocpref_ga00887b728c214e4d85d50ac0d0d1f9dd}\index{Section allocation: malloc or mmap@{Section allocation: malloc or mmap}!dwarf\_get\_mmap\_count@{dwarf\_get\_mmap\_count}}
\index{dwarf\_get\_mmap\_count@{dwarf\_get\_mmap\_count}!Section allocation: malloc or mmap@{Section allocation: malloc or mmap}}
\doxysubsubsection{\texorpdfstring{dwarf\_get\_mmap\_count()}{dwarf\_get\_mmap\_count()}}
{\footnotesize\ttfamily \label{group__sectionallocpref_ga00887b728c214e4d85d50ac0d0d1f9dd} 
DW\+\_\+\+API int dwarf\+\_\+get\+\_\+mmap\+\_\+count (\begin{DoxyParamCaption}\item[{\doxymbox{\hyperlink{group__allstructs_gac2ba1e1c1b70a3191506b414195ca807}{Dwarf\+\_\+\+Debug}}}]{dw\+\_\+dbg}{, }\item[{\doxymbox{\hyperlink{group__basicdatatypes_ga5de64bb9627534a24dcbccc327916265}{Dwarf\+\_\+\+Unsigned}} \texorpdfstring{$\ast$}{*}}]{dw\+\_\+mmap\+\_\+count}{, }\item[{\doxymbox{\hyperlink{group__basicdatatypes_ga5de64bb9627534a24dcbccc327916265}{Dwarf\+\_\+\+Unsigned}} \texorpdfstring{$\ast$}{*}}]{dw\+\_\+mmap\+\_\+size}{, }\item[{\doxymbox{\hyperlink{group__basicdatatypes_ga5de64bb9627534a24dcbccc327916265}{Dwarf\+\_\+\+Unsigned}} \texorpdfstring{$\ast$}{*}}]{dw\+\_\+malloc\+\_\+count}{, }\item[{\doxymbox{\hyperlink{group__basicdatatypes_ga5de64bb9627534a24dcbccc327916265}{Dwarf\+\_\+\+Unsigned}} \texorpdfstring{$\ast$}{*}}]{dw\+\_\+malloc\+\_\+size}{}\end{DoxyParamCaption})}



Retrieve count of mmap/\+malloc sections. 

\begin{DoxySince}{Since}
\{0.\+12.\+0\}
\end{DoxySince}
Note that compressed section contents will be expanded into a malloc/\+read section in all cases.


\begin{DoxyParams}{Parameters}
{\em dw\+\_\+dbg} & A valid open \doxylink{group__allstructs_gac2ba1e1c1b70a3191506b414195ca807}{Dwarf\+\_\+\+Debug}. \\
\hline
{\em dw\+\_\+mmap\+\_\+count} & On success the number of sections allocated with mmap is returned. If null passed in the argument is ignored. \\
\hline
{\em dw\+\_\+mmap\+\_\+size} & On success the size total in bytes of sections allocated with mmap is returned. If null passed in the argument is ignored. \\
\hline
{\em dw\+\_\+malloc\+\_\+count} & On success the number of sections read/\+allocated with read/\+malloc is returned. If null passed in the argument is ignored. On success the number of sections allocated with malloc/\+read is returned. \\
\hline
{\em dw\+\_\+malloc\+\_\+size} & On success the total size in bytes of sections with malloc/\+read is returned. If null passed in the argument is ignored. On success the number of sections read/\+allocated with read/\+malloc is returned.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
On success returns DW\+\_\+\+DLV\+\_\+\+OK and sets the counts and total size through the respective non-\/null pointer arguments. If dw\+\_\+dbg is invalid or NULL the function returns DW\+\_\+\+DLV\+\_\+\+ERROR. Never returns DW\+\_\+\+DLV\+\_\+\+NO\+\_\+\+ENTRY. 
\end{DoxyReturn}
\Hypertarget{group__sectionallocpref_ga38895d41776523190f5c7e2af4f6391c}\index{Section allocation: malloc or mmap@{Section allocation: malloc or mmap}!dwarf\_set\_load\_preference@{dwarf\_set\_load\_preference}}
\index{dwarf\_set\_load\_preference@{dwarf\_set\_load\_preference}!Section allocation: malloc or mmap@{Section allocation: malloc or mmap}}
\doxysubsubsection{\texorpdfstring{dwarf\_set\_load\_preference()}{dwarf\_set\_load\_preference()}}
{\footnotesize\ttfamily \label{group__sectionallocpref_ga38895d41776523190f5c7e2af4f6391c} 
DW\+\_\+\+API enum \doxymbox{\hyperlink{group__allstructs_ga8e19573b56799157d063d8cc2828f69b}{Dwarf\+\_\+\+Sec\+\_\+\+Alloc\+\_\+\+Pref}} dwarf\+\_\+set\+\_\+load\+\_\+preference (\begin{DoxyParamCaption}\item[{enum \doxymbox{\hyperlink{group__allstructs_ga8e19573b56799157d063d8cc2828f69b}{Dwarf\+\_\+\+Sec\+\_\+\+Alloc\+\_\+\+Pref}}}]{dw\+\_\+load\+\_\+preference}{}\end{DoxyParamCaption})}



Set/\+\+Retrieve section allocation preference. 

\begin{DoxySince}{Since}
\{0.\+12.\+0\}
\end{DoxySince}
By default object file sections are loaded using malloc and read (Dwarf\+\_\+\+Alloc\+\_\+\+Malloc). This works everywhere and works well on all but gigantic object files.

The preference of Dwarf\+\_\+\+Alloc\+\_\+\+Mmap does not guarantee mmap will be used for object section data, but does cause mmap() to be used when possible.

In 0.\+12.\+0 mmap() is only usable on Elf object files.

dw\+\_\+load\+\_\+preference is one of Dwarf\+\_\+\+Alloc\+\_\+\+Malloc (1) Dwarf\+\_\+\+Alloc\+\_\+\+Mmap (2)

Must be called before calling a dwarf\+\_\+init\texorpdfstring{$\ast$}{*}() to be effective in a dwarf\+\_\+init\texorpdfstring{$\ast$}{*}(). The value is remembered for subsequent dwarf\+\_\+init\texorpdfstring{$\ast$}{*}() in the library runtime being executed.


\begin{DoxyParams}{Parameters}
{\em dw\+\_\+load\+\_\+preference} & If passed in Dwarf\+\_\+\+Alloc\+\_\+\+Mmap then future calls to any dwarf\+\_\+init\texorpdfstring{$\ast$}{*}() function will use mmap to load object sections if possible. If passed in Dwarf\+\_\+\+Alloc\+\_\+\+Malloc then future calls to any dwarf\+\_\+init\texorpdfstring{$\ast$}{*}() function will use mmap to load sections. Any other value passed in dw\+\_\+load\+\_\+preference is ignored. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
Always returns the value before dw\+\_\+load\+\_\+preference applied, of this runtime global preference. 
\end{DoxyReturn}
