rationalize list handling in mutt a bit.
[apps/madmutt.git] / alias.c
diff --git a/alias.c b/alias.c
index 32b6df3..dc5084b 100644 (file)
--- a/alias.c
+++ b/alias.c
@@ -44,12 +44,6 @@ static struct mapping_t AliasHelp[] = {
     {NULL, OP_NULL}
 };
 
-void alias_wipe(alias_t *a) {
-    p_delete(&a->name);
-    address_delete(&a->addr);
-    alias_delete(&a->next);
-}
-
 const address_t *alias_lookup(const alias_t *list, const char *s)
 {
     while (list) {
@@ -214,7 +208,7 @@ void mutt_create_alias(ENVELOPE *cur, address_t *iadr)
         const char *err = NULL;
 
         if (mutt_get_field(_("Address: "), buf, sizeof(buf), 0) || !buf[0]) {
-            alias_delete(&new);
+            alias_list_wipe(&new);
             return;
         }
 
@@ -236,7 +230,7 @@ void mutt_create_alias(ENVELOPE *cur, address_t *iadr)
     }
 
     if (mutt_get_field(_("Personal name: "), buf, sizeof(buf), 0)) {
-        alias_delete(&new);
+        alias_list_wipe(&new);
         return;
     }
     new->addr->personal = m_strdup(buf);
@@ -245,7 +239,7 @@ void mutt_create_alias(ENVELOPE *cur, address_t *iadr)
     rfc822_write_address(buf, sizeof(buf), new->addr, 1);
     snprintf(prompt, sizeof(prompt), _("[%s = %s] Accept?"), new->name, buf);
     if (mutt_yesorno(prompt, M_YES) != M_YES) {
-        alias_delete(&new);
+        alias_list_wipe(&new);
         return;
     }
 
@@ -277,7 +271,7 @@ void mutt_create_alias(ENVELOPE *cur, address_t *iadr)
     }
 }
 
-static address_t *mutt_expand_aliases_r(address_t *a, LIST **expn)
+static address_t *mutt_expand_aliases_r(address_t *a, string_list_t **expn)
 {
     address_t *pop, *head = NULL;
     address_t **last = &head;
@@ -289,21 +283,21 @@ static address_t *mutt_expand_aliases_r(address_t *a, LIST **expn)
             const address_t *t = alias_lookup(Aliases, pop->mailbox);
 
             if (t) {
-                LIST *u;
+                string_list_t *u;
 
                 for (u = *expn; u; u = u->next) {
                     if (!m_strcmp(pop->mailbox, u->data)) { /* alias already found */
-                        address_delete(&pop);
+                        address_list_wipe(&pop);
                         continue;
                     }
                 }
 
                 /* save the fact we saw it */
-                u = mutt_new_list();
+                u = string_item_new();
                 u->data = m_strdup(pop->mailbox);
                 u->next = *expn;
                 *expn = u;
-                address_delete(&pop);
+                address_list_wipe(&pop);
 
                 /* recurse */
                 last  = address_list_last(last);
@@ -336,10 +330,10 @@ static address_t *mutt_expand_aliases_r(address_t *a, LIST **expn)
 address_t *mutt_expand_aliases(address_t *a)
 {
     address_t *t;
-    LIST *expn = NULL;            /* previously expanded aliases to avoid loops */
+    string_list_t *expn = NULL;            /* previously expanded aliases to avoid loops */
 
     t = mutt_expand_aliases_r(a, &expn);
-    mutt_free_list(&expn);
+    string_list_wipe(&expn);
     return mutt_remove_duplicates(t);
 }
 
@@ -458,7 +452,7 @@ int mutt_alias_complete (char *s, size_t buflen)
         Aliases = a_cur->next;
 
       a_cur->next = NULL;
-      alias_delete(&a_cur);
+      alias_list_wipe(&a_cur);
 
       if (a_list)
         a_cur = a_list;