Fix pseudo handling on rehash (#1305452).
authorMichael Poole <mdpoole@troilus.org>
Tue, 27 Sep 2005 03:54:46 +0000 (03:54 +0000)
committerMichael Poole <mdpoole@troilus.org>
Tue, 27 Sep 2005 03:54:46 +0000 (03:54 +0000)
git-svn-id: file:///home/klmitch/undernet-ircu/undernet-ircu-svn/ircu2/trunk@1497 c9e4aea6-c8fd-4c43-8297-357d70d61c8c

ChangeLog
ircd/parse.c

index 208dff96ac1f106453058720d33611c9fa12dd53..bf5a87519484041754d175dee616433b6c87f426 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2005-09-26  Michael Poole <mdpoole@troilus.org>
+
+       * ircd/parse.c (del_msg_element): Only delete empty subtrees, and
+       leave subtrees that may still contain data.
+
 2005-09-26  Michael Poole <mdpoole@troilus.org>
 
        * include/channel.h (struct ModeBuf): Add mbm_oplevel to args
index 84dc1be9ee0bc92e4ad89bd9ae0d2b8e2ae5f733..692433b94c923bd5e579d0980e411323dfc0bd33 100644 (file)
@@ -678,20 +678,28 @@ add_msg_element(struct MessageTree *mtree_p, struct Message *msg_p, char *cmd)
  * @param[in,out] mtree_p Trie node to remove command from.
  * @param[in] cmd Text of command to remove.
  */
-void
+struct MessageTree *
 del_msg_element(struct MessageTree *mtree_p, char *cmd)
 {
-  struct MessageTree *ntree_p;
+  int slot = *cmd & (MAXPTRLEN-1);
 
+  /* Either remove leaf message or from appropriate child. */
   if (*cmd == '\0')
-    return;
-
-  if ((ntree_p = mtree_p->pointers[*cmd & (MAXPTRLEN-1)]) != NULL)
-  {
-    del_msg_element(ntree_p, cmd+1);
-    MyFree(ntree_p);
-    mtree_p->pointers[*cmd & (MAXPTRLEN-1)] = NULL;
-  }
+    mtree_p->msg = NULL;
+  else
+    mtree_p->pointers[slot] = del_msg_element(mtree_p->pointers[slot], cmd + 1);
+
+  /* If current message or any child still exists, keep this node. */
+  if (mtree_p->msg)
+    return mtree_p;
+  for (slot = 0; slot < MAXPTRLEN; ++slot)
+    if (mtree_p->pointers[slot])
+      return mtree_p;
+
+  /* Otherwise, if we're not a root node, free it and return null. */
+  if (mtree_p != &msg_tree && mtree_p != &tok_tree)
+    MyFree(mtree_p);
+  return NULL;
 }
 
 /** Initialize the message lookup trie with all known commands. */