\hypertarget{group__Eina__Binshare__Group}{}\doxysection{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.  


\doxysubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \mbox{\hyperlink{group__Eina__Binshare__Group_ga1472e150f4fbaa3f05e5c583b1698b40}{eina\+\_\+binshare\+\_\+add}}(ptr)~\mbox{\hyperlink{group__Eina__Binshare__Group_ga1967e55339f2f641c059f5904fec3356}{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}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
\mbox{\hyperlink{group__Eina__Types__Group_ga6ac08753ba12bc9c7a0390cf67868f4f}{EINA\+\_\+\+API}} const void $\ast$ \mbox{\hyperlink{group__Eina__Binshare__Group_ga1967e55339f2f641c059f5904fec3356}{eina\+\_\+binshare\+\_\+add\+\_\+length}} (const void $\ast$obj, unsigned int olen)
\begin{DoxyCompactList}\small\item\em Retrieves an instance of an object for use in a program. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__Eina__Types__Group_ga6ac08753ba12bc9c7a0390cf67868f4f}{EINA\+\_\+\+API}} const void $\ast$ \mbox{\hyperlink{group__Eina__Binshare__Group_ga3889ca8137d1a416f9c76bd577e6b937}{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__Eina__Types__Group_ga6ac08753ba12bc9c7a0390cf67868f4f}{EINA\+\_\+\+API}} void \mbox{\hyperlink{group__Eina__Binshare__Group_gabe2c4df515e2baa7c85c491bbf063d3b}{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__Eina__Types__Group_ga6ac08753ba12bc9c7a0390cf67868f4f}{EINA\+\_\+\+API}} int \mbox{\hyperlink{group__Eina__Binshare__Group_gae5555c4edf5d37bc54171b35a846c24f}{eina\+\_\+binshare\+\_\+length}} (const void $\ast$obj)
\begin{DoxyCompactList}\small\item\em Notes that the given object {\bfseries{must}} be shared. \end{DoxyCompactList}\item 
\mbox{\hyperlink{group__Eina__Types__Group_ga6ac08753ba12bc9c7a0390cf67868f4f}{EINA\+\_\+\+API}} void \mbox{\hyperlink{group__Eina__Binshare__Group_ga7573c320f719401eac10a189accf585e}{eina\+\_\+binshare\+\_\+dump}} (void)
\begin{DoxyCompactList}\small\item\em Dumps the contents of share\+\_\+common. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{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}}. 

\doxysubsection{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}}
\doxysubsubsection{\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_ga1967e55339f2f641c059f5904fec3356}{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 NULL}, then {\ttfamily NULL} 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{\texttt{ 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 NULL} 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_ga1901668fffca5f06ace9b150715dfc76}{eina\+\_\+stringshare\+\_\+add\+\_\+length()}} 
\end{DoxySeeAlso}


\doxysubsection{Function Documentation}
\mbox{\Hypertarget{group__Eina__Binshare__Group_ga1967e55339f2f641c059f5904fec3356}\label{group__Eina__Binshare__Group_ga1967e55339f2f641c059f5904fec3356}} 
\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}}
\doxysubsubsection{\texorpdfstring{eina\_binshare\_add\_length()}{eina\_binshare\_add\_length()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__Eina__Types__Group_ga6ac08753ba12bc9c7a0390cf67868f4f}{EINA\+\_\+\+API}} 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{\texttt{ in}}  & {\em obj} & The binary object to retrieve an instance of \\
\hline
\mbox{\texttt{ in}}  & {\em olen} & The byte size \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
A pointer to an instance of the object on success, otherwise {\ttfamily NULL} on failure
\end{DoxyReturn}
This function retrieves an instance of {\ttfamily obj}. If {\ttfamily obj} is {\ttfamily NULL}, then {\ttfamily NULL} 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_ga3889ca8137d1a416f9c76bd577e6b937}\label{group__Eina__Binshare__Group_ga3889ca8137d1a416f9c76bd577e6b937}} 
\index{Binary Share@{Binary Share}!eina\_binshare\_ref@{eina\_binshare\_ref}}
\index{eina\_binshare\_ref@{eina\_binshare\_ref}!Binary Share@{Binary Share}}
\doxysubsubsection{\texorpdfstring{eina\_binshare\_ref()}{eina\_binshare\_ref()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__Eina__Types__Group_ga6ac08753ba12bc9c7a0390cf67868f4f}{EINA\+\_\+\+API}} 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{\texttt{ in}}  & {\em obj} & The shared object \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
A pointer to an instance of the object on success, otherwise {\ttfamily NULL} 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_gabe2c4df515e2baa7c85c491bbf063d3b}{eina\+\_\+binshare\+\_\+del()}}. 
\end{DoxyNote}
\mbox{\Hypertarget{group__Eina__Binshare__Group_gabe2c4df515e2baa7c85c491bbf063d3b}\label{group__Eina__Binshare__Group_gabe2c4df515e2baa7c85c491bbf063d3b}} 
\index{Binary Share@{Binary Share}!eina\_binshare\_del@{eina\_binshare\_del}}
\index{eina\_binshare\_del@{eina\_binshare\_del}!Binary Share@{Binary Share}}
\doxysubsubsection{\texorpdfstring{eina\_binshare\_del()}{eina\_binshare\_del()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__Eina__Types__Group_ga6ac08753ba12bc9c7a0390cf67868f4f}{EINA\+\_\+\+API}} 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{\texttt{ 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 NULL}, 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_gae5555c4edf5d37bc54171b35a846c24f}\label{group__Eina__Binshare__Group_gae5555c4edf5d37bc54171b35a846c24f}} 
\index{Binary Share@{Binary Share}!eina\_binshare\_length@{eina\_binshare\_length}}
\index{eina\_binshare\_length@{eina\_binshare\_length}!Binary Share@{Binary Share}}
\doxysubsubsection{\texorpdfstring{eina\_binshare\_length()}{eina\_binshare\_length()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__Eina__Types__Group_ga6ac08753ba12bc9c7a0390cf67868f4f}{EINA\+\_\+\+API}} 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{\texttt{ in}}  & {\em obj} & The shared object to know the length ~\newline
 It is safe to give {\ttfamily NULL}, 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_ga7573c320f719401eac10a189accf585e}\label{group__Eina__Binshare__Group_ga7573c320f719401eac10a189accf585e}} 
\index{Binary Share@{Binary Share}!eina\_binshare\_dump@{eina\_binshare\_dump}}
\index{eina\_binshare\_dump@{eina\_binshare\_dump}!Binary Share@{Binary Share}}
\doxysubsubsection{\texorpdfstring{eina\_binshare\_dump()}{eina\_binshare\_dump()}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__Eina__Types__Group_ga6ac08753ba12bc9c7a0390cf67868f4f}{EINA\+\_\+\+API}} 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 DDD\+: prefix per line and a memory usage summary. 