drop mem_alloc and mem_free, use my own hand crafted optmized macros that
[apps/madmutt.git] / imap / util.c
index a55168a..1025cea 100644 (file)
@@ -13,6 +13,8 @@
 
 #include "config.h"
 
+#include <lib-lib/mem.h>
+
 #include "mutt.h"
 #include "mx.h"                 /* for M_IMAP */
 #include "ascii.h"
@@ -57,7 +59,7 @@ int imap_expand_path (char *path, size_t len)
   url.path = mx.mbox;
 
   rc = url_ciss_tostring (&url, path, len, U_DECODE_PASSWD);
-  mem_free (&mx.mbox);
+  p_delete(&mx.mbox);
 
   return rc;
 }
@@ -100,7 +102,7 @@ int imap_parse_path (const char *path, IMAP_MBOX * mx)
 
   if (!(url.scheme == U_IMAP || url.scheme == U_IMAPS) ||
       mutt_account_fromurl (&mx->account, &url) < 0 || !*mx->account.host) {
-    mem_free (&c);
+    p_delete(&c);
     return -1;
   }
 
@@ -109,7 +111,7 @@ int imap_parse_path (const char *path, IMAP_MBOX * mx)
   if (url.scheme == U_IMAPS)
     mx->account.flags |= M_ACCT_SSL;
 
-  mem_free (&c);
+  p_delete(&c);
 
   if ((mx->account.flags & M_ACCT_SSL) && !(mx->account.flags & M_ACCT_PORT))
     mx->account.port = ImapsPort;
@@ -144,7 +146,7 @@ void imap_pretty_mailbox (char *path)
           if (target.mbox[hlen] == *delim)
             home_match = 1;
     }
-    mem_free (&home.mbox);
+    p_delete(&home.mbox);
   }
 
   /* do the '=' substitution */
@@ -165,7 +167,7 @@ void imap_pretty_mailbox (char *path)
     url_ciss_tostring (&url, path, 1024, 0);
   }
 
-  mem_free (&target.mbox);
+  p_delete(&target.mbox);
 }
 
 /* -- library functions -- */
@@ -198,10 +200,10 @@ void imap_free_idata (IMAP_DATA ** idata)
   if (!idata)
     return;
 
-  mem_free (&(*idata)->capstr);
+  p_delete(&(*idata)->capstr);
   mutt_free_list (&(*idata)->flags);
-  mem_free (&((*idata)->cmd.buf));
-  mem_free (idata);
+  p_delete(&((*idata)->cmd.buf));
+  p_delete(idata);
 }
 
 /*
@@ -430,7 +432,7 @@ void imap_munge_mbox_name (char *dest, size_t dlen, const char *src)
 
   imap_quote_string (dest, dlen, buf);
 
-  mem_free (&buf);
+  p_delete(&buf);
 }
 
 void imap_unmunge_mbox_name (char *s)
@@ -445,7 +447,7 @@ void imap_unmunge_mbox_name (char *s)
     strncpy (s, buf, str_len (s));
   }
 
-  mem_free (&buf);
+  p_delete(&buf);
 }
 
 /* imap_wordcasecmp: find word a in word list b */
@@ -500,7 +502,7 @@ void imap_keepalive (void)
         }
         imap_check_mailbox (ctx, NULL, 1);
         if (!idata->ctx)
-          mem_free (&ctx);
+          p_delete(&ctx);
       }
     }
 
@@ -516,9 +518,11 @@ int imap_wait_keepalive (pid_t pid)
   int rc;
 
   short imap_passive = option (OPTIMAPPASSIVE);
+  int imap_askreconnect = quadoption (OPT_IMAPRECONNECT);
 
   set_option (OPTIMAPPASSIVE);
   set_option (OPTKEEPQUIET);
+  set_quadoption (OPT_IMAPRECONNECT, M_NO);
 
   sigprocmask (SIG_SETMASK, NULL, &oldmask);
 
@@ -547,6 +551,7 @@ int imap_wait_keepalive (pid_t pid)
   unset_option (OPTKEEPQUIET);
   if (!imap_passive)
     unset_option (OPTIMAPPASSIVE);
+  set_quadoption (OPT_IMAPRECONNECT, imap_askreconnect);
 
   return rc;
 }