]> jfr.im git - irc/evilnet/x3.git/blobdiff - src/dict-splay.c
testing again
[irc/evilnet/x3.git] / src / dict-splay.c
index 5f37b1d205e98f8e33e8cdc0154d6d4b92427ec0..1e473503666e39b0e22a102c2b27bc5a6df0672b 100644 (file)
@@ -67,22 +67,6 @@ dict_foreach(dict_t dict, dict_iterator_f it_f, void *extra)
     return NULL;
 }
 
-/* We seem to find ourselves in a situation where callbacks sometimes contain
- * data pointers to users who have been killed and deleted by previously hooked
- * callbacks. This function provides a way to check for that before using
- * what will be unallocated memory pointed to by an old pointer. */
-unsigned int
-dict_validptr(dict_t dict, void *data)
-{
-    dict_iterator_t it;
-    for (it=dict_first(dict); it; it=iter_next(it)) {
-        if(iter_data(it) == data)
-            return true;
-    }
-    return false;
-}
-
-
 /*
  *   This function finds a node and pulls it to the top of the tree.
  *   This helps balance the tree and auto-cache things you search for.
@@ -94,6 +78,7 @@ dict_splay(struct dict_node *node, const char *key)
     int res;
 
     if (!node) return NULL;
+    if (!key) return NULL;
     N.l = N.r = NULL;
     l = r = &N;
 
@@ -244,6 +229,7 @@ dict_remove2(dict_t dict, const char *key, int no_dispose)
 
     if (!dict->root)
         return 0;
+    if (!key) return 0;
     verify(dict);
     dict->root = dict_splay(dict->root, key);
     if (irccasecmp(key, dict->root->key))
@@ -320,20 +306,20 @@ dict_sanity_check_node(struct dict_node *node, struct dict_sanity_struct *dss)
 {
     verify(node);
     if (!node->key) {
-        snprintf(dss->error, sizeof(dss->error), "Node %p had null key", node);
+        snprintf(dss->error, sizeof(dss->error), "Node %p had null key", (void*)node);
         return 1;
     }
     if (node->l) {
         if (dict_sanity_check_node(node->l, dss)) return 1;
         if (irccasecmp(node->l->key, node->key) >= 0) {
-            snprintf(dss->error, sizeof(dss->error), "Node %p's left child's key '%s' >= its key '%s'", node, node->l->key, node->key);
+            snprintf(dss->error, sizeof(dss->error), "Node %p's left child's key '%s' >= its key '%s'", (void*)node, node->l->key, node->key);
             return 1;
         }
     }
     if (node->r) {
         if (dict_sanity_check_node(node->r, dss)) return 1;
         if (irccasecmp(node->key, node->r->key) >= 0) {
-            snprintf(dss->error, sizeof(dss->error), "Node %p's right child's key '%s' <= its key '%s'", node, node->r->key, node->key);
+            snprintf(dss->error, sizeof(dss->error), "Node %p's right child's key '%s' <= its key '%s'", (void*)node, node->r->key, node->key);
             return 1;
         }
     }