\hypertarget{group__Eina__Safepointer__Group}{}\doxysection{Safe Pointer}
\label{group__Eina__Safepointer__Group}\index{Safe Pointer@{Safe Pointer}}


These functions provide a wrapper that protect access to pointers.  


\doxysubsection*{Typedefs}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{group__Eina__Safepointer__Group_gaceb5489a49e4ff5eb71fe0e261707010}\label{group__Eina__Safepointer__Group_gaceb5489a49e4ff5eb71fe0e261707010}} 
typedef struct \+\_\+\+Eina\+\_\+\+Safepointer \mbox{\hyperlink{group__Eina__Safepointer__Group_gaceb5489a49e4ff5eb71fe0e261707010}{Eina\+\_\+\+Safepointer}}
\begin{DoxyCompactList}\small\item\em Type of the protected index. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
const \mbox{\hyperlink{group__Eina__Safepointer__Group_gaceb5489a49e4ff5eb71fe0e261707010}{Eina\+\_\+\+Safepointer}} $\ast$ \mbox{\hyperlink{group__Eina__Safepointer__Group_ga939ea9ad94c3c393c1845d053c94667b}{eina\+\_\+safepointer\+\_\+register}} (const void $\ast$target)
\begin{DoxyCompactList}\small\item\em Register a pointer and get an Eina\+\_\+\+Safepointer that maps to it. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{group__Eina__Safepointer__Group_ga184e4557df8e3ea16ae8b9f65c7c636d}{eina\+\_\+safepointer\+\_\+unregister}} (const \mbox{\hyperlink{group__Eina__Safepointer__Group_gaceb5489a49e4ff5eb71fe0e261707010}{Eina\+\_\+\+Safepointer}} $\ast$safe)
\begin{DoxyCompactList}\small\item\em Unregister an Eina\+\_\+\+Safepointer and the pointer that maps to it. \end{DoxyCompactList}\item 
static void $\ast$ \mbox{\hyperlink{group__Eina__Safepointer__Group_ga2202ee963589cf46aad92612e10c0533}{eina\+\_\+safepointer\+\_\+get}} (const \mbox{\hyperlink{group__Eina__Safepointer__Group_gaceb5489a49e4ff5eb71fe0e261707010}{Eina\+\_\+\+Safepointer}} $\ast$safe)
\begin{DoxyCompactList}\small\item\em Get the associated pointer from an Eina\+\_\+\+Safepointer mapping. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
These functions provide a wrapper that protect access to pointers. 

Eina\+\_\+\+Safepointer is an pointer to index converter that allows an increased level of safety by forbidding direct access to the pointer. The protection works by using a set of indirection tables that are mmapped and mprotected against write access. Thus the pointer they store and that map to a specific index is always correct. Also once a pointer is unregistered the index won\textquotesingle{}t be served back for 2$^\wedge$8 on 32 bits system and 2$^\wedge$28 on 64 bits system for that specific slot. Finally we guarantee that the lower 2 bits of the returned index are actually never used and completely ignored by our API. So you can safely store whatever information you want in it, we will ignore it and treat as if it wasn\textquotesingle{}t there.

\begin{DoxyNote}{Note}
The use of Eina\+\_\+\+Safepointer is thread safe. 
\end{DoxyNote}


\doxysubsection{Function Documentation}
\mbox{\Hypertarget{group__Eina__Safepointer__Group_ga939ea9ad94c3c393c1845d053c94667b}\label{group__Eina__Safepointer__Group_ga939ea9ad94c3c393c1845d053c94667b}} 
\index{Safe Pointer@{Safe Pointer}!eina\_safepointer\_register@{eina\_safepointer\_register}}
\index{eina\_safepointer\_register@{eina\_safepointer\_register}!Safe Pointer@{Safe Pointer}}
\doxysubsubsection{\texorpdfstring{eina\_safepointer\_register()}{eina\_safepointer\_register()}}
{\footnotesize\ttfamily const \mbox{\hyperlink{group__Eina__Safepointer__Group_gaceb5489a49e4ff5eb71fe0e261707010}{Eina\+\_\+\+Safepointer}}$\ast$ eina\+\_\+safepointer\+\_\+register (\begin{DoxyParamCaption}\item[{const void $\ast$}]{target }\end{DoxyParamCaption})}



Register a pointer and get an Eina\+\_\+\+Safepointer that maps to it. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em target} & The pointer to register. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
A valid pointer that is an index to the mapped pointer.
\end{DoxyReturn}
\begin{DoxyNote}{Note}
It will return {\ttfamily NULL} on error or if {\ttfamily target} is {\ttfamily NULL}.

The lower 2 bits of the returned pointer will always be 0.

The returned pointer can be used like a pointer, but cannot be touched except with Eina\+\_\+\+Safepointer functions.
\end{DoxyNote}
\begin{DoxySince}{Since}
1.\+18 
\end{DoxySince}


References eina\+\_\+spinlock\+\_\+release(), and eina\+\_\+spinlock\+\_\+take().

\mbox{\Hypertarget{group__Eina__Safepointer__Group_ga184e4557df8e3ea16ae8b9f65c7c636d}\label{group__Eina__Safepointer__Group_ga184e4557df8e3ea16ae8b9f65c7c636d}} 
\index{Safe Pointer@{Safe Pointer}!eina\_safepointer\_unregister@{eina\_safepointer\_unregister}}
\index{eina\_safepointer\_unregister@{eina\_safepointer\_unregister}!Safe Pointer@{Safe Pointer}}
\doxysubsubsection{\texorpdfstring{eina\_safepointer\_unregister()}{eina\_safepointer\_unregister()}}
{\footnotesize\ttfamily void eina\+\_\+safepointer\+\_\+unregister (\begin{DoxyParamCaption}\item[{const \mbox{\hyperlink{group__Eina__Safepointer__Group_gaceb5489a49e4ff5eb71fe0e261707010}{Eina\+\_\+\+Safepointer}} $\ast$}]{safe }\end{DoxyParamCaption})}



Unregister an Eina\+\_\+\+Safepointer and the pointer that maps to it. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em safe} & The index to unregister from the mapping.\\
\hline
\end{DoxyParams}
\begin{DoxyNote}{Note}
This function will ignore the lower 2 bits of the given pointer.
\end{DoxyNote}
\begin{DoxySince}{Since}
1.\+18 
\end{DoxySince}


References eina\+\_\+spinlock\+\_\+release(), eina\+\_\+spinlock\+\_\+take(), and eina\+\_\+trash\+\_\+push().

\mbox{\Hypertarget{group__Eina__Safepointer__Group_ga2202ee963589cf46aad92612e10c0533}\label{group__Eina__Safepointer__Group_ga2202ee963589cf46aad92612e10c0533}} 
\index{Safe Pointer@{Safe Pointer}!eina\_safepointer\_get@{eina\_safepointer\_get}}
\index{eina\_safepointer\_get@{eina\_safepointer\_get}!Safe Pointer@{Safe Pointer}}
\doxysubsubsection{\texorpdfstring{eina\_safepointer\_get()}{eina\_safepointer\_get()}}
{\footnotesize\ttfamily static void$\ast$ eina\+\_\+safepointer\+\_\+get (\begin{DoxyParamCaption}\item[{const \mbox{\hyperlink{group__Eina__Safepointer__Group_gaceb5489a49e4ff5eb71fe0e261707010}{Eina\+\_\+\+Safepointer}} $\ast$}]{safe }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [static]}}



Get the associated pointer from an Eina\+\_\+\+Safepointer mapping. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em safe} & The Eina\+\_\+\+Safepointer index to lookup at. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The pointer registered with that index or {\ttfamily NULL} in any other case.
\end{DoxyReturn}
\begin{DoxyNote}{Note}
It is always safe to ask for a pointer for any value of the mapping. If the pointer is invalid or {\ttfamily NULL}, we will return {\ttfamily NULL} and not crash. 
\end{DoxyNote}
