\hypertarget{group__Eina__Binshare__Group}{}\section{Binary Share}
\label{group__Eina__Binshare__Group}\index{Binary Share@{Binary Share}}


This group discusses the functions that allow you to store one copy of an object, and use it throughout your program.  


\subsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \mbox{\hyperlink{group__Eina__Binshare__Group_ga1472e150f4fbaa3f05e5c583b1698b40}{eina\+\_\+binshare\+\_\+add}}(ptr)~\mbox{\hyperlink{group__Eina__Binshare__Group_ga376ff9324527657d65627d9630c5da07}{eina\+\_\+binshare\+\_\+add\+\_\+length}}(ptr, sizeof($\ast$ptr))
\begin{DoxyCompactList}\small\item\em Retrieves an instance of a blob for use in a program. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
\mbox{\hyperlink{group__Elua_ga3db3556eec8ef18cb8ddb43816974ac8}{E\+A\+PI}} const void $\ast$ \mbox{\hyperlink{group__Eina__Binshare__Group_ga376ff9324527657d65627d9630c5da07}{eina\+\_\+binshare\+\_\+add\+\_\+length}} (const void $\ast$obj, unsigned int olen) \mbox{\hyperlink{group__Eina__Types__Group_ga4ba89e4b58eff707a6cf05ffe0cd4dea}{E\+I\+N\+A\+\_\+\+W\+A\+R\+N\+\_\+\+U\+N\+U\+S\+E\+D\+\_\+\+R\+E\+S\+U\+LT}}
\begin{DoxyCompactList}\small\item\em Retrieves an instance of an object for use in a program. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__Elua_ga3db3556eec8ef18cb8ddb43816974ac8}{E\+A\+PI}} const void $\ast$ \mbox{\hyperlink{group__Eina__Binshare__Group_ga7637cf798dfdf90ce7d0bed8738e8c33}{eina\+\_\+binshare\+\_\+ref}} (const void $\ast$obj)
\begin{DoxyCompactList}\small\item\em Increments references of the given shared object. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__Elua_ga3db3556eec8ef18cb8ddb43816974ac8}{E\+A\+PI}} void \mbox{\hyperlink{group__Eina__Binshare__Group_gac4083405412aa0713805fea3444fbaa3}{eina\+\_\+binshare\+\_\+del}} (const void $\ast$obj)
\begin{DoxyCompactList}\small\item\em Notes that the given object has lost an instance. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__Elua_ga3db3556eec8ef18cb8ddb43816974ac8}{E\+A\+PI}} int \mbox{\hyperlink{group__Eina__Binshare__Group_ga2fe833551e802405367099585f44cd76}{eina\+\_\+binshare\+\_\+length}} (const void $\ast$obj) \mbox{\hyperlink{group__Eina__Types__Group_ga4ba89e4b58eff707a6cf05ffe0cd4dea}{E\+I\+N\+A\+\_\+\+W\+A\+R\+N\+\_\+\+U\+N\+U\+S\+E\+D\+\_\+\+R\+E\+S\+U\+LT}} \mbox{\hyperlink{group__Eina__Types__Group_ga4669a55a23089d0f9b70702ef05cea68}{E\+I\+N\+A\+\_\+\+P\+U\+RE}}
\begin{DoxyCompactList}\small\item\em Notes that the given object {\bfseries must} be shared. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__Elua_ga3db3556eec8ef18cb8ddb43816974ac8}{E\+A\+PI}} void \mbox{\hyperlink{group__Eina__Binshare__Group_gafd5871a8191c3afd846480144d8287dd}{eina\+\_\+binshare\+\_\+dump}} (void)
\begin{DoxyCompactList}\small\item\em Dumps the contents of share\+\_\+common. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
This group discusses the functions that allow you to store one copy of an object, and use it throughout your program. 

This is a method to reduce the number of duplicated objects kept in the memory.

For more information, you can look at the \mbox{\hyperlink{tutorial_binshare_page}{Binary Share Tutorial}}. 

\subsection{Macro Definition Documentation}
\mbox{\Hypertarget{group__Eina__Binshare__Group_ga1472e150f4fbaa3f05e5c583b1698b40}\label{group__Eina__Binshare__Group_ga1472e150f4fbaa3f05e5c583b1698b40}} 
\index{Binary Share@{Binary Share}!eina\+\_\+binshare\+\_\+add@{eina\+\_\+binshare\+\_\+add}}
\index{eina\+\_\+binshare\+\_\+add@{eina\+\_\+binshare\+\_\+add}!Binary Share@{Binary Share}}
\subsubsection{\texorpdfstring{eina\+\_\+binshare\+\_\+add}{eina\_binshare\_add}}
{\footnotesize\ttfamily \#define eina\+\_\+binshare\+\_\+add(\begin{DoxyParamCaption}\item[{}]{ptr }\end{DoxyParamCaption})~\mbox{\hyperlink{group__Eina__Binshare__Group_ga376ff9324527657d65627d9630c5da07}{eina\+\_\+binshare\+\_\+add\+\_\+length}}(ptr, sizeof($\ast$ptr))}



Retrieves an instance of a blob for use in a program. 

This macro retrieves an instance of {\ttfamily obj}. If {\ttfamily obj} is {\ttfamily N\+U\+LL}, then {\ttfamily N\+U\+LL} is returned. If {\ttfamily obj} is already stored, it is just returned and its reference counter is increased. Otherwise it is added to the blobs to be searched and a duplicated blob of {\ttfamily obj} is returned. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em ptr} & The binary blob to retrieve an instance of \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
A pointer to an instance of the string on success, otherwise {\ttfamily N\+U\+LL} on failure
\end{DoxyReturn}
\begin{DoxyNote}{Note}
This macro essentially calls eina\+\_\+binshare\+\_\+add\+\_\+length with ptr and sizeof($\ast$ptr) as the parameters. It\textquotesingle{}s useful for pointers to structures.
\end{DoxyNote}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__Eina__Stringshare__Group_gabe8ecf4121011cb792f36ecd8c44e470}{eina\+\_\+stringshare\+\_\+add\+\_\+length()}} 
\end{DoxySeeAlso}


\subsection{Function Documentation}
\mbox{\Hypertarget{group__Eina__Binshare__Group_ga376ff9324527657d65627d9630c5da07}\label{group__Eina__Binshare__Group_ga376ff9324527657d65627d9630c5da07}} 
\index{Binary Share@{Binary Share}!eina\+\_\+binshare\+\_\+add\+\_\+length@{eina\+\_\+binshare\+\_\+add\+\_\+length}}
\index{eina\+\_\+binshare\+\_\+add\+\_\+length@{eina\+\_\+binshare\+\_\+add\+\_\+length}!Binary Share@{Binary Share}}
\subsubsection{\texorpdfstring{eina\+\_\+binshare\+\_\+add\+\_\+length()}{eina\_binshare\_add\_length()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__Elua_ga3db3556eec8ef18cb8ddb43816974ac8}{E\+A\+PI}} const void$\ast$ eina\+\_\+binshare\+\_\+add\+\_\+length (\begin{DoxyParamCaption}\item[{const void $\ast$}]{obj,  }\item[{unsigned int}]{olen }\end{DoxyParamCaption})}



Retrieves an instance of an object for use in a program. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em obj} & The binary object to retrieve an instance of \\
\hline
\mbox{\tt in}  & {\em olen} & The byte size \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
A pointer to an instance of the object on success, otherwise {\ttfamily N\+U\+LL} on failure
\end{DoxyReturn}
This function retrieves an instance of {\ttfamily obj}. If {\ttfamily obj} is {\ttfamily N\+U\+LL}, then {\ttfamily N\+U\+LL} is returned. If {\ttfamily obj} is already stored, it is just returned and its reference counter is increased. Otherwise it is added to the objects to be searched and a duplicated object of {\ttfamily obj} is returned.

\begin{DoxyNote}{Note}
This function does not check the object size, but uses the exact given size. This can be used to share a part of a larger object or subobject.
\end{DoxyNote}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__Eina__Binshare__Group_ga1472e150f4fbaa3f05e5c583b1698b40}{eina\+\_\+binshare\+\_\+add()}} 
\end{DoxySeeAlso}
\mbox{\Hypertarget{group__Eina__Binshare__Group_ga7637cf798dfdf90ce7d0bed8738e8c33}\label{group__Eina__Binshare__Group_ga7637cf798dfdf90ce7d0bed8738e8c33}} 
\index{Binary Share@{Binary Share}!eina\+\_\+binshare\+\_\+ref@{eina\+\_\+binshare\+\_\+ref}}
\index{eina\+\_\+binshare\+\_\+ref@{eina\+\_\+binshare\+\_\+ref}!Binary Share@{Binary Share}}
\subsubsection{\texorpdfstring{eina\+\_\+binshare\+\_\+ref()}{eina\_binshare\_ref()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__Elua_ga3db3556eec8ef18cb8ddb43816974ac8}{E\+A\+PI}} const void$\ast$ eina\+\_\+binshare\+\_\+ref (\begin{DoxyParamCaption}\item[{const void $\ast$}]{obj }\end{DoxyParamCaption})}



Increments references of the given shared object. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em obj} & The shared object \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
A pointer to an instance of the object on success, otherwise {\ttfamily N\+U\+LL} on failure
\end{DoxyReturn}
\begin{DoxyNote}{Note}
This is similar to eina\+\_\+share\+\_\+common\+\_\+add(), but it\textquotesingle{}s faster since it avoids lookups if possible, but on the down side it requires the parameter to be shared before, in other words, it must be the return of a previous \mbox{\hyperlink{group__Eina__Binshare__Group_ga1472e150f4fbaa3f05e5c583b1698b40}{eina\+\_\+binshare\+\_\+add()}}.

There is no unref since this is the work of \mbox{\hyperlink{group__Eina__Binshare__Group_gac4083405412aa0713805fea3444fbaa3}{eina\+\_\+binshare\+\_\+del()}}. 
\end{DoxyNote}
\mbox{\Hypertarget{group__Eina__Binshare__Group_gac4083405412aa0713805fea3444fbaa3}\label{group__Eina__Binshare__Group_gac4083405412aa0713805fea3444fbaa3}} 
\index{Binary Share@{Binary Share}!eina\+\_\+binshare\+\_\+del@{eina\+\_\+binshare\+\_\+del}}
\index{eina\+\_\+binshare\+\_\+del@{eina\+\_\+binshare\+\_\+del}!Binary Share@{Binary Share}}
\subsubsection{\texorpdfstring{eina\+\_\+binshare\+\_\+del()}{eina\_binshare\_del()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__Elua_ga3db3556eec8ef18cb8ddb43816974ac8}{E\+A\+PI}} void eina\+\_\+binshare\+\_\+del (\begin{DoxyParamCaption}\item[{const void $\ast$}]{obj }\end{DoxyParamCaption})}



Notes that the given object has lost an instance. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em obj} & The given object\\
\hline
\end{DoxyParams}
This function decreases the reference counter associated to {\ttfamily obj} if it exists. If that counter reaches {\ttfamily 0}, the memory associated to {\ttfamily obj} is freed. If {\ttfamily obj} is {\ttfamily N\+U\+LL}, the function returns immediately.

\begin{DoxyWarning}{Warning}
If the given pointer is not shared, bad things happen, mostly a segmentation fault. 
\end{DoxyWarning}
\mbox{\Hypertarget{group__Eina__Binshare__Group_ga2fe833551e802405367099585f44cd76}\label{group__Eina__Binshare__Group_ga2fe833551e802405367099585f44cd76}} 
\index{Binary Share@{Binary Share}!eina\+\_\+binshare\+\_\+length@{eina\+\_\+binshare\+\_\+length}}
\index{eina\+\_\+binshare\+\_\+length@{eina\+\_\+binshare\+\_\+length}!Binary Share@{Binary Share}}
\subsubsection{\texorpdfstring{eina\+\_\+binshare\+\_\+length()}{eina\_binshare\_length()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__Elua_ga3db3556eec8ef18cb8ddb43816974ac8}{E\+A\+PI}} int eina\+\_\+binshare\+\_\+length (\begin{DoxyParamCaption}\item[{const void $\ast$}]{obj }\end{DoxyParamCaption})}



Notes that the given object {\bfseries must} be shared. 

This function is a cheap way to know the length of a shared object. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em obj} & The shared object to know the length ~\newline
 It is safe to give {\ttfamily N\+U\+LL}, in which case {\ttfamily -\/1} is returned \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The length of the shared object
\end{DoxyReturn}
\begin{DoxyWarning}{Warning}
If the given pointer is not shared, bad things happen, mostly a segmentation fault. If in doubt, try strlen(). 
\end{DoxyWarning}
\mbox{\Hypertarget{group__Eina__Binshare__Group_gafd5871a8191c3afd846480144d8287dd}\label{group__Eina__Binshare__Group_gafd5871a8191c3afd846480144d8287dd}} 
\index{Binary Share@{Binary Share}!eina\+\_\+binshare\+\_\+dump@{eina\+\_\+binshare\+\_\+dump}}
\index{eina\+\_\+binshare\+\_\+dump@{eina\+\_\+binshare\+\_\+dump}!Binary Share@{Binary Share}}
\subsubsection{\texorpdfstring{eina\+\_\+binshare\+\_\+dump()}{eina\_binshare\_dump()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__Elua_ga3db3556eec8ef18cb8ddb43816974ac8}{E\+A\+PI}} void eina\+\_\+binshare\+\_\+dump (\begin{DoxyParamCaption}\item[{void}]{ }\end{DoxyParamCaption})}



Dumps the contents of share\+\_\+common. 

This function dumps all the objects from share\+\_\+common to stdout with a D\+DD\+: prefix per line and a memory usage summary. 