Code

src/utils_threshold.h: Documented the public functions.
[collectd.git] / src / utils_avltree.c
index 786bc38f9d026d3ead7ab973db07ebe45982e239..285dd3853e57fe7831b63ad204ff4ca00a0b0c4a 100644 (file)
@@ -19,6 +19,9 @@
  * Authors:
  *   Florian octo Forster <octo at verplant.org>
  **/
+
+#include "config.h"
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -515,7 +518,7 @@ int avl_insert (avl_tree_t *t, void *key, void *value)
                if (cmp == 0)
                {
                        free_node (new);
-                       return (-1);
+                       return (1);
                }
                else if (cmp < 0)
                {
@@ -578,13 +581,12 @@ int avl_get (avl_tree_t *t, const void *key, void **value)
 {
        avl_node_t *n;
 
-       assert (value != NULL);
-
        n = search (t, key);
        if (n == NULL)
                return (-1);
 
-       *value = n->value;
+       if (value != NULL)
+               *value = n->value;
 
        return (0);
 }