\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 {\bfseries Eina\+\_\+\+Safepointer}
\begin{DoxyCompactList}\small\item\em Type of the protected index. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
\mbox{\hyperlink{group__Eina__Types__Group_ga6ac08753ba12bc9c7a0390cf67868f4f}{EINA\+\_\+\+API}} const \mbox{\hyperlink{group__Eina__Safepointer__Group_gaceb5489a49e4ff5eb71fe0e261707010}{Eina\+\_\+\+Safepointer}} $\ast$ \mbox{\hyperlink{group__Eina__Safepointer__Group_ga60faf92920945ba9e9f2e9975f7638d7}{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 
\mbox{\hyperlink{group__Eina__Types__Group_ga6ac08753ba12bc9c7a0390cf67868f4f}{EINA\+\_\+\+API}} void \mbox{\hyperlink{group__Eina__Safepointer__Group_gaf9ccfb391328af447306998be237cd57}{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_ga439b0b248c34c7a733d8f77ddd099cd2}{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_ga60faf92920945ba9e9f2e9975f7638d7}\label{group__Eina__Safepointer__Group_ga60faf92920945ba9e9f2e9975f7638d7}} 
\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 \mbox{\hyperlink{group__Eina__Types__Group_ga6ac08753ba12bc9c7a0390cf67868f4f}{EINA\+\_\+\+API}} 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}
\mbox{\Hypertarget{group__Eina__Safepointer__Group_gaf9ccfb391328af447306998be237cd57}\label{group__Eina__Safepointer__Group_gaf9ccfb391328af447306998be237cd57}} 
\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 \mbox{\hyperlink{group__Eina__Types__Group_ga6ac08753ba12bc9c7a0390cf67868f4f}{EINA\+\_\+\+API}} 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}
\mbox{\Hypertarget{group__Eina__Safepointer__Group_ga439b0b248c34c7a733d8f77ddd099cd2}\label{group__Eina__Safepointer__Group_ga439b0b248c34c7a733d8f77ddd099cd2}} 
\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}
