summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f46cf59)
raw | patch | inline | side by side (parent: f46cf59)
author | Luke Heberling <collectd@c-ware.com> | |
Thu, 13 Dec 2007 07:15:38 +0000 (08:15 +0100) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Thu, 13 Dec 2007 07:15:38 +0000 (08:15 +0100) |
I'd like to be able to tell when avl_insert fails because of a duplicate key as
opposed to when it fails due to out of memory or other condition.
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
opposed to when it fails due to out of memory or other condition.
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
src/utils_avltree.c | patch | blob | history | |
src/utils_avltree.h | patch | blob | history |
diff --git a/src/utils_avltree.c b/src/utils_avltree.c
index 09cf2e6fee238f246780d5b191d22bb54f6c6f14..031ec477965e61868775278f129a412f4bec1c17 100644 (file)
--- a/src/utils_avltree.c
+++ b/src/utils_avltree.c
if (cmp == 0)
{
free_node (new);
- return (-1);
+ return (1);
}
else if (cmp < 0)
{
diff --git a/src/utils_avltree.h b/src/utils_avltree.h
index 7a29a2942e569d1aa66f3dc31177c751c073214d..0fc8ea15997dbe922994a4c73335a1da1d7ac895 100644 (file)
--- a/src/utils_avltree.h
+++ b/src/utils_avltree.h
* `value' Value to be stored.
*
* RETURN VALUE
- * Zero upon success and non-zero upon failure and if the key is already
- * stored in the tree.
+ * Zero upon success, non-zero otherwise. It's less than zero if an error
+ * occurred or greater than zero if the key is already stored in the tree.
*/
int avl_insert (avl_tree_t *t, void *key, void *value);