* tables of power of two in size are used, collisions are handled by
* chaining. See the source code for more information... :)
*
* tables of power of two in size are used, collisions are handled by
* chaining. See the source code for more information... :)
*
-/* Add an element, discarding the old if the key already exists */
+/* Add an element, discarding the old if the key already exists.
+ * Return 1 if the key was added from scratch, 0 if there was already an
+ * element with such key and dictReplace() just performed a value update
+ * operation. */
/* Try to add the element. If the key
* does not exists dictAdd will suceed. */
if (dictAdd(ht, key, val) == DICT_OK)
/* Try to add the element. If the key
* does not exists dictAdd will suceed. */
if (dictAdd(ht, key, val) == DICT_OK)
/* It already exists, get the entry */
entry = dictFind(ht, key);
/* Free the old value and set the new one */
dictFreeEntryVal(ht, entry);
dictSetHashVal(ht, entry, val);
/* It already exists, get the entry */
entry = dictFind(ht, key);
/* Free the old value and set the new one */
dictFreeEntryVal(ht, entry);
dictSetHashVal(ht, entry, val);