\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_ga1a6631b960ee18c848192b6ea7ff1b18}{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 
const void $\ast$ \mbox{\hyperlink{group__Eina__Binshare__Group_ga1a6631b960ee18c848192b6ea7ff1b18}{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 
const void $\ast$ \mbox{\hyperlink{group__Eina__Binshare__Group_ga65b8a32d90f5c71368a33aff5910f68f}{eina\+\_\+binshare\+\_\+ref}} (const void $\ast$obj)
\begin{DoxyCompactList}\small\item\em Increments references of the given shared object. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{group__Eina__Binshare__Group_ga9d27dea908363feae9b580abacf52383}{eina\+\_\+binshare\+\_\+del}} (const void $\ast$obj)
\begin{DoxyCompactList}\small\item\em Notes that the given object has lost an instance. \end{DoxyCompactList}\item 
int \mbox{\hyperlink{group__Eina__Binshare__Group_ga6c4a177729e140b930e140b5e3d7fdfc}{eina\+\_\+binshare\+\_\+length}} (const void $\ast$obj)
\begin{DoxyCompactList}\small\item\em Notes that the given object {\bfseries{must}} be shared. \end{DoxyCompactList}\item 
void \mbox{\hyperlink{group__Eina__Binshare__Group_gaecc9a06d58c91fcf7c1b01ad01dca045}{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_ga1a6631b960ee18c848192b6ea7ff1b18}{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_gabe8ecf4121011cb792f36ecd8c44e470}{eina\+\_\+stringshare\+\_\+add\+\_\+length()}} 
\end{DoxySeeAlso}


\doxysubsection{Function Documentation}
\mbox{\Hypertarget{group__Eina__Binshare__Group_ga1a6631b960ee18c848192b6ea7ff1b18}\label{group__Eina__Binshare__Group_ga1a6631b960ee18c848192b6ea7ff1b18}} 
\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 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_ga65b8a32d90f5c71368a33aff5910f68f}\label{group__Eina__Binshare__Group_ga65b8a32d90f5c71368a33aff5910f68f}} 
\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 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_ga9d27dea908363feae9b580abacf52383}{eina\+\_\+binshare\+\_\+del()}}. 
\end{DoxyNote}
\mbox{\Hypertarget{group__Eina__Binshare__Group_ga9d27dea908363feae9b580abacf52383}\label{group__Eina__Binshare__Group_ga9d27dea908363feae9b580abacf52383}} 
\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 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_ga6c4a177729e140b930e140b5e3d7fdfc}\label{group__Eina__Binshare__Group_ga6c4a177729e140b930e140b5e3d7fdfc}} 
\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 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_gaecc9a06d58c91fcf7c1b01ad01dca045}\label{group__Eina__Binshare__Group_gaecc9a06d58c91fcf7c1b01ad01dca045}} 
\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 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. 