+/* whowas_clean()
+ *
+ * Clean up a whowas structure
+ */
+static struct Whowas *
+whowas_clean(struct Whowas *ww)
+{
+ if (!ww)
+ return 0;
+
+ Debug((DEBUG_LIST, "Cleaning whowas structure for %s", ww->name));
+
+ if (ww->online) { /* unlink from client */
+ if (ww->cnext) /* shouldn't happen, but I'm not confident of that */
+ ww->cnext->cprevnextp = ww->cprevnextp;
+ *ww->cprevnextp = ww->cnext;
+ }
+
+ if (ww->hnext) /* now unlink from hash table */
+ ww->hnext->hprevnextp = ww->hprevnextp;
+ *ww->hprevnextp = ww->hnext;
+
+ if (ww->wnext) /* unlink from whowas linked list... */
+ ww->wnext->wprev = ww->wprev;
+ if (ww->wprev)
+ ww->wprev->wnext = ww->wnext;
+
+ if (wwList.ww_tail == ww) /* update tail pointer appropriately */
+ wwList.ww_tail = ww->wprev;
+
+ /* Free old info */
+ if (ww->name)
+ MyFree(ww->name);
+ if (ww->username)
+ MyFree(ww->username);
+ if (ww->hostname)
+ MyFree(ww->hostname);
+ if (ww->servername)
+ MyFree(ww->servername);
+ if (ww->realname)
+ MyFree(ww->realname);
+ if (ww->away)
+ MyFree(ww->away);
+
+ return ww;
+}
+
+/* whowas_free()
+ *
+ * Free a struct Whowas...
+ */
+static void
+whowas_free(struct Whowas *ww)
+{
+ if (!ww)
+ return;
+
+ Debug((DEBUG_LIST, "Destroying whowas structure for %s", ww->name));
+
+ MyFree(whowas_clean(ww));