From d928a9ded82f3d5607dd44fc681892970f6c027e Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Tue, 27 Jul 2010 09:41:34 +0000 Subject: [PATCH] Eina: implement the macro eina_binshare_add. SVN revision: 50535 --- legacy/eina/src/include/Eina.h | 1 + legacy/eina/src/include/eina_binshare.h | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/legacy/eina/src/include/Eina.h b/legacy/eina/src/include/Eina.h index f44d1840fc..717e59c809 100644 --- a/legacy/eina/src/include/Eina.h +++ b/legacy/eina/src/include/Eina.h @@ -53,6 +53,7 @@ * @author Raphael Kubo da Costa * @author Tilman Sauerbeck * @author Vincent "caro" Torri + * @author Tom Hacohen * @date 2008-2010 * * @section eina_intro_sec Introduction diff --git a/legacy/eina/src/include/eina_binshare.h b/legacy/eina/src/include/eina_binshare.h index 3d67f394f9..03f56534b1 100644 --- a/legacy/eina/src/include/eina_binshare.h +++ b/legacy/eina/src/include/eina_binshare.h @@ -68,12 +68,31 @@ EAPI Eina_Bool eina_binshare_init(void); EAPI Eina_Bool eina_binshare_shutdown(void); EAPI const char *eina_binshare_add_length(const char *str, unsigned int slen) EINA_WARN_UNUSED_RESULT; -EAPI const char *eina_binshare_add(const char *str) EINA_WARN_UNUSED_RESULT; EAPI const char *eina_binshare_ref(const char *str); EAPI void eina_binshare_del(const char *str); EAPI int eina_binshare_length(const char *str) EINA_CONST EINA_WARN_UNUSED_RESULT; EAPI void eina_binshare_dump(void); +/** + * @brief Retrieve an instance of a blob for use in a program. + * + * @param str The binary blob to retrieve an instance of. + * @return A pointer to an instance of the string on success. + * @c NULL on failure. + * + * This macro retrieves an instance of @p str. If @p str is + * @c NULL, then @c NULL is returned. If @p str 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 @p str is returned. + * + * This macro essentially calls eina_binshare_add_length with ptr and sizeof(*ptr) + * as the parameters. It's useful for pointers to structures. + * + * @see eina_stringshare_add_length() + */ +#define eina_binshare_add(ptr) eina_binshare_add_length(ptr, sizeof(*ptr)) + /** * @} */