From 1a571fc6895be30ba4fab155b9ecb212bb8ea0ec Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Thu, 21 Aug 2014 13:47:59 +0200 Subject: [PATCH] eina: add documentation for the tricky eina_hash_pointer_new --- src/lib/eina/eina_hash.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/lib/eina/eina_hash.h b/src/lib/eina/eina_hash.h index 15cc7b4694..4681a47164 100644 --- a/src/lib/eina/eina_hash.h +++ b/src/lib/eina/eina_hash.h @@ -499,6 +499,15 @@ EAPI Eina_Hash *eina_hash_int64_new(Eina_Free_Cb data_free_cb); * original key pointer that was used to add values. This method may * appear to be able to match string keys, actually it only matches * the first character. On failure, this function returns @c NULL. + * + * @code + * // For a hash that will have only one pointer to each structure + * extern Eina_Hash *hash; + * extern void *data; + * + * if (!eina_hash_find(hash, &data)) + * eina_hash_add(hash, &data, data); + * @endcode */ EAPI Eina_Hash *eina_hash_pointer_new(Eina_Free_Cb data_free_cb); @@ -523,7 +532,7 @@ EAPI Eina_Hash *eina_hash_pointer_new(Eina_Free_Cb data_free_cb); * const char *a = eina_stringshare_add("key"); * * eina_hash_add(hash, a, value); - * eina_hash_find(hash, "key") + * eina_hash_find(hash, "key"); * @endcode */ EAPI Eina_Hash *eina_hash_stringshared_new(Eina_Free_Cb data_free_cb);