Rocco Rutte:
[apps/madmutt.git] / browser.c
index 2046a37..3ed8a11 100644 (file)
--- a/browser.c
+++ b/browser.c
 #endif
 
 #include "mutt.h"
 #endif
 
 #include "mutt.h"
+#include "mx.h"
 #include "mutt_curses.h"
 #include "mutt_menu.h"
 #include "buffy.h"
 #include "mapping.h"
 #include "sort.h"
 #include "browser.h"
 #include "mutt_curses.h"
 #include "mutt_menu.h"
 #include "buffy.h"
 #include "mapping.h"
 #include "sort.h"
 #include "browser.h"
+#include "attach.h"
+
 #ifdef USE_IMAP
 #include "imap.h"
 #ifdef USE_IMAP
 #include "imap.h"
+#include "imap/mx_imap.h"
 #endif
 #ifdef USE_NNTP
 #include "nntp.h"
 #endif
 #ifdef USE_NNTP
 #include "nntp.h"
@@ -74,14 +78,14 @@ static void destroy_state (struct browser_state *state)
   int c;
 
   for (c = 0; c < state->entrylen; c++) {
   int c;
 
   for (c = 0; c < state->entrylen; c++) {
-    FREE (&((state->entry)[c].name));
-    FREE (&((state->entry)[c].desc));
-    FREE (&((state->entry)[c].st));
+    mem_free (&((state->entry)[c].name));
+    mem_free (&((state->entry)[c].desc));
+    mem_free (&((state->entry)[c].st));
   }
 #ifdef USE_IMAP
   }
 #ifdef USE_IMAP
-  FREE (&state->folder);
+  mem_free (&state->folder);
 #endif
 #endif
-  FREE (&state->entry);
+  mem_free (&state->entry);
 }
 
 static int browser_compare_subject (const void *a, const void *b)
 }
 
 static int browser_compare_subject (const void *a, const void *b)
@@ -89,7 +93,7 @@ static int browser_compare_subject (const void *a, const void *b)
   struct folder_file *pa = (struct folder_file *) a;
   struct folder_file *pb = (struct folder_file *) b;
 
   struct folder_file *pa = (struct folder_file *) a;
   struct folder_file *pb = (struct folder_file *) b;
 
-  int r = safe_strcoll (pa->name, pb->name);
+  int r = str_coll (pa->name, pb->name);
 
   return ((BrowserSort & SORT_REVERSE) ? -r : r);
 }
 
   return ((BrowserSort & SORT_REVERSE) ? -r : r);
 }
@@ -270,7 +274,7 @@ static const char *folder_format_str (char *dest, size_t destlen, char op,
 
   case 'N':
 #ifdef USE_IMAP
 
   case 'N':
 #ifdef USE_IMAP
-    if (mx_is_imap (folder->ff->desc)) {
+    if (imap_is_magic (folder->ff->desc, NULL) == M_IMAP) {
       if (!optional) {
         snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
         snprintf (dest, destlen, tmp, folder->ff->new);
       if (!optional) {
         snprintf (tmp, sizeof (tmp), "%%%sd", fmt);
         snprintf (dest, destlen, tmp, folder->ff->new);
@@ -422,7 +426,7 @@ static void add_folder (MUTTMENU * m, struct browser_state *state,
 {
   if (state->entrylen == state->entrymax) {
     /* need to allocate more space */
 {
   if (state->entrylen == state->entrymax) {
     /* need to allocate more space */
-    safe_realloc (&state->entry,
+    mem_realloc (&state->entry,
                   sizeof (struct folder_file) * (state->entrymax += 256));
     memset (&state->entry[state->entrylen], 0,
             sizeof (struct folder_file) * 256);
                   sizeof (struct folder_file) * (state->entrymax += 256));
     memset (&state->entry[state->entrylen], 0,
             sizeof (struct folder_file) * 256);
@@ -435,13 +439,13 @@ static void add_folder (MUTTMENU * m, struct browser_state *state,
     (state->entry)[state->entrylen].mtime = s->st_mtime;
     (state->entry)[state->entrylen].size = s->st_size;
 
     (state->entry)[state->entrylen].mtime = s->st_mtime;
     (state->entry)[state->entrylen].size = s->st_size;
 
-    (state->entry)[state->entrylen].st = safe_malloc (sizeof (struct stat));
+    (state->entry)[state->entrylen].st = mem_malloc (sizeof (struct stat));
     memcpy ((state->entry)[state->entrylen].st, s, sizeof (struct stat));
   }
 
   (state->entry)[state->entrylen].new = new;
     memcpy ((state->entry)[state->entrylen].st, s, sizeof (struct stat));
   }
 
   (state->entry)[state->entrylen].new = new;
-  (state->entry)[state->entrylen].name = safe_strdup (name);
-  (state->entry)[state->entrylen].desc = safe_strdup (name);
+  (state->entry)[state->entrylen].name = str_dup (name);
+  (state->entry)[state->entrylen].desc = str_dup (name);
 #ifdef USE_IMAP
   (state->entry)[state->entrylen].imap = 0;
 #endif
 #ifdef USE_IMAP
   (state->entry)[state->entrylen].imap = 0;
 #endif
@@ -457,7 +461,7 @@ static void init_state (struct browser_state *state, MUTTMENU * menu)
   state->entrylen = 0;
   state->entrymax = 256;
   state->entry =
   state->entrylen = 0;
   state->entrymax = 256;
   state->entry =
-    (struct folder_file *) safe_calloc (state->entrymax,
+    (struct folder_file *) mem_calloc (state->entrymax,
                                         sizeof (struct folder_file));
 #ifdef USE_IMAP
   state->imap_browse = 0;
                                         sizeof (struct folder_file));
 #ifdef USE_IMAP
   state->imap_browse = 0;
@@ -476,14 +480,14 @@ static int examine_directory (MUTTMENU * menu, struct browser_state *state,
     NNTP_DATA *data;
     NNTP_SERVER *news = CurrentNewsSrv;
 
     NNTP_DATA *data;
     NNTP_SERVER *news = CurrentNewsSrv;
 
-/*  mutt_buffy_check (0); */
+/*  buffy_check (0); */
     init_state (state, menu);
 
     for (tmp = news->list; tmp; tmp = tmp->next) {
       if (!(data = (NNTP_DATA *) tmp->data))
         continue;
       if (prefix && *prefix && strncmp (prefix, data->group,
     init_state (state, menu);
 
     for (tmp = news->list; tmp; tmp = tmp->next) {
       if (!(data = (NNTP_DATA *) tmp->data))
         continue;
       if (prefix && *prefix && strncmp (prefix, data->group,
-                                        safe_strlen (prefix)) != 0)
+                                        str_len (prefix)) != 0)
         continue;
       if (!((regexec (Mask.rx, data->group, 0, NULL, 0) == 0) ^ Mask.not))
         continue;
         continue;
       if (!((regexec (Mask.rx, data->group, 0, NULL, 0) == 0) ^ Mask.not))
         continue;
@@ -518,7 +522,7 @@ static int examine_directory (MUTTMENU * menu, struct browser_state *state,
       return (-1);
     }
 
       return (-1);
     }
 
-    mutt_buffy_check (0);
+    buffy_check (0);
 
     if ((dp = opendir (d)) == NULL) {
       mutt_perror (d);
 
     if ((dp = opendir (d)) == NULL) {
       mutt_perror (d);
@@ -528,11 +532,11 @@ static int examine_directory (MUTTMENU * menu, struct browser_state *state,
     init_state (state, menu);
 
     while ((de = readdir (dp)) != NULL) {
     init_state (state, menu);
 
     while ((de = readdir (dp)) != NULL) {
-      if (safe_strcmp (de->d_name, ".") == 0)
+      if (str_cmp (de->d_name, ".") == 0)
         continue;               /* we don't need . */
 
       if (prefix && *prefix
         continue;               /* we don't need . */
 
       if (prefix && *prefix
-          && safe_strncmp (prefix, de->d_name, safe_strlen (prefix)) != 0)
+          && str_ncmp (prefix, de->d_name, str_len (prefix)) != 0)
         continue;
       if (!((regexec (Mask.rx, de->d_name, 0, NULL, 0) == 0) ^ Mask.not))
         continue;
         continue;
       if (!((regexec (Mask.rx, de->d_name, 0, NULL, 0) == 0) ^ Mask.not))
         continue;
@@ -567,7 +571,7 @@ static int examine_mailboxes (MUTTMENU * menu, struct browser_state *state)
     NNTP_DATA *data;
     NNTP_SERVER *news = CurrentNewsSrv;
 
     NNTP_DATA *data;
     NNTP_SERVER *news = CurrentNewsSrv;
 
-/*  mutt_buffy_check (0); */
+/*  buffy_check (0); */
     init_state (state, menu);
 
     for (tmp = news->list; tmp; tmp = tmp->next) {
     init_state (state, menu);
 
     for (tmp = news->list; tmp; tmp = tmp->next) {
@@ -588,26 +592,27 @@ static int examine_mailboxes (MUTTMENU * menu, struct browser_state *state)
 
     if (!Incoming)
       return (-1);
 
     if (!Incoming)
       return (-1);
-    mutt_buffy_check (0);
+    buffy_check (0);
 
     init_state (state, menu);
 
     for (i = 0; i < Incoming->length; i++) {
       tmp = (BUFFY*) Incoming->data[i];
 
     init_state (state, menu);
 
     for (i = 0; i < Incoming->length; i++) {
       tmp = (BUFFY*) Incoming->data[i];
+      tmp->magic = mx_get_magic (tmp->path);
 #ifdef USE_IMAP
 #ifdef USE_IMAP
-      if (mx_is_imap (tmp->path)) {
+      if (tmp->magic == M_IMAP) {
         add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
         continue;
       }
 #endif
 #ifdef USE_POP
         add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
         continue;
       }
 #endif
 #ifdef USE_POP
-      if (mx_is_pop (tmp->path)) {
+      if (tmp->magic == M_POP) {
         add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
         continue;
       }
 #endif
 #ifdef USE_NNTP
         add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
         continue;
       }
 #endif
 #ifdef USE_NNTP
-      if (mx_is_nntp (tmp->path)) {
+      if (tmp->magic == M_NNTP) {
         add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
         continue;
       }
         add_folder (menu, state, tmp->path, NULL, NULL, tmp->new);
         continue;
       }
@@ -684,7 +689,7 @@ static void init_menu (struct browser_state *state, MUTTMENU * menu,
   else
 #endif
   if (buffy)
   else
 #endif
   if (buffy)
-    snprintf (title, titlelen, _("Mailboxes [%d]"), mutt_buffy_check (0));
+    snprintf (title, titlelen, _("Mailboxes [%d]"), buffy_check (0));
   else {
     strfcpy (path, LastDir, sizeof (path));
     mutt_pretty_mailbox (path);
   else {
     strfcpy (path, LastDir, sizeof (path));
     mutt_pretty_mailbox (path);
@@ -764,15 +769,15 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
   if (*f) {
     mutt_expand_path (f, flen);
 #ifdef USE_IMAP
   if (*f) {
     mutt_expand_path (f, flen);
 #ifdef USE_IMAP
-    if (mx_is_imap (f)) {
+    if (imap_is_magic (f, NULL) == M_IMAP) {
       init_state (&state, NULL);
       state.imap_browse = 1;
       init_state (&state, NULL);
       state.imap_browse = 1;
-      imap_browse (f, &state);
-      strfcpy (LastDir, state.folder, sizeof (LastDir));
+      if (!imap_browse (f, &state))
+        strfcpy (LastDir, state.folder, sizeof (LastDir));
     }
     else {
 #endif
     }
     else {
 #endif
-      for (i = safe_strlen (f) - 1; i > 0 && f[i] != '/'; i--);
+      for (i = str_len (f) - 1; i > 0 && f[i] != '/'; i--);
       if (i > 0) {
         if (f[0] == '/') {
           if (i > sizeof (LastDir) - 1)
       if (i > 0) {
         if (f[0] == '/') {
           if (i > sizeof (LastDir) - 1)
@@ -782,8 +787,8 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
         }
         else {
           getcwd (LastDir, sizeof (LastDir));
         }
         else {
           getcwd (LastDir, sizeof (LastDir));
-          safe_strcat (LastDir, sizeof (LastDir), "/");
-          safe_strncat (LastDir, sizeof (LastDir), f, i);
+          str_cat (LastDir, sizeof (LastDir), "/");
+          str_ncat (LastDir, sizeof (LastDir), f, i);
         }
       }
       else {
         }
       }
       else {
@@ -809,7 +814,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
       strfcpy (LastDir, NONULL (Maildir), sizeof (LastDir));
 
 #ifdef USE_IMAP
       strfcpy (LastDir, NONULL (Maildir), sizeof (LastDir));
 
 #ifdef USE_IMAP
-    if (!buffy && mx_is_imap (LastDir)) {
+    if (!buffy && imap_is_magic (LastDir, NULL) == M_IMAP) {
       init_state (&state, NULL);
       state.imap_browse = 1;
       imap_browse (LastDir, &state);
       init_state (&state, NULL);
       state.imap_browse = 1;
       imap_browse (LastDir, &state);
@@ -888,8 +893,8 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
           /* save the old directory */
           strfcpy (OldLastDir, LastDir, sizeof (OldLastDir));
 
           /* save the old directory */
           strfcpy (OldLastDir, LastDir, sizeof (OldLastDir));
 
-          if (safe_strcmp (state.entry[menu->current].name, "..") == 0) {
-            if (safe_strcmp ("..", LastDir + safe_strlen (LastDir) - 2) == 0)
+          if (str_cmp (state.entry[menu->current].name, "..") == 0) {
+            if (str_cmp ("..", LastDir + str_len (LastDir) - 2) == 0)
               strcat (LastDir, "/..");  /* __STRCAT_CHECKED__ */
             else {
               char *p = strrchr (LastDir + 1, '/');
               strcat (LastDir, "/..");  /* __STRCAT_CHECKED__ */
             else {
               char *p = strrchr (LastDir + 1, '/');
@@ -917,7 +922,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
             strfcpy (LastDir, state.entry[menu->current].name,
                      sizeof (LastDir));
             /* tack on delimiter here */
             strfcpy (LastDir, state.entry[menu->current].name,
                      sizeof (LastDir));
             /* tack on delimiter here */
-            n = safe_strlen (LastDir) + 1;
+            n = str_len (LastDir) + 1;
 
             /* special case "" needs no delimiter */
             url_parse_ciss (&url, state.entry[menu->current].name);
 
             /* special case "" needs no delimiter */
             url_parse_ciss (&url, state.entry[menu->current].name);
@@ -993,7 +998,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
 
         if (menu->tagged) {
           *numfiles = menu->tagged;
 
         if (menu->tagged) {
           *numfiles = menu->tagged;
-          tfiles = safe_calloc (*numfiles, sizeof (char *));
+          tfiles = mem_calloc (*numfiles, sizeof (char *));
           for (i = 0, j = 0; i < state.entrylen; i++) {
             struct folder_file ff = state.entry[i];
             char full[_POSIX_PATH_MAX];
           for (i = 0, j = 0; i < state.entrylen; i++) {
             struct folder_file ff = state.entry[i];
             char full[_POSIX_PATH_MAX];
@@ -1001,16 +1006,16 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
             if (ff.tagged) {
               mutt_concat_path (full, LastDir, ff.name, sizeof (full));
               mutt_expand_path (full, sizeof (full));
             if (ff.tagged) {
               mutt_concat_path (full, LastDir, ff.name, sizeof (full));
               mutt_expand_path (full, sizeof (full));
-              tfiles[j++] = safe_strdup (full);
+              tfiles[j++] = str_dup (full);
             }
           }
           *files = tfiles;
         }
         else if (f[0]) {        /* no tagged entries. return selected entry */
           *numfiles = 1;
             }
           }
           *files = tfiles;
         }
         else if (f[0]) {        /* no tagged entries. return selected entry */
           *numfiles = 1;
-          tfiles = safe_calloc (*numfiles, sizeof (char *));
+          tfiles = mem_calloc (*numfiles, sizeof (char *));
           mutt_expand_path (f, flen);
           mutt_expand_path (f, flen);
-          tfiles[0] = safe_strdup (f);
+          tfiles[0] = str_dup (f);
           *files = tfiles;
         }
       }
           *files = tfiles;
         }
       }
@@ -1088,8 +1093,8 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
         if (mutt_yesorno (msg, M_NO) == M_YES) {
           if (!imap_delete_mailbox (Context, mx)) {
             /* free the mailbox from the browser */
         if (mutt_yesorno (msg, M_NO) == M_YES) {
           if (!imap_delete_mailbox (Context, mx)) {
             /* free the mailbox from the browser */
-            FREE (&((state.entry)[nentry].name));
-            FREE (&((state.entry)[nentry].desc));
+            mem_free (&((state.entry)[nentry].name));
+            mem_free (&((state.entry)[nentry].desc));
             /* and move all other entries up */
             if (nentry + 1 < state.entrylen)
               memmove (state.entry + nentry, state.entry + nentry + 1,
             /* and move all other entries up */
             if (nentry + 1 < state.entrylen)
               memmove (state.entry + nentry, state.entry + nentry + 1,
@@ -1104,7 +1109,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
         }
         else
           mutt_message _("Mailbox not deleted.");
         }
         else
           mutt_message _("Mailbox not deleted.");
-        FREE (&mx.mbox);
+        mem_free (&mx.mbox);
       }
       break;
 #endif
       }
       break;
 #endif
@@ -1122,7 +1127,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
 #endif
       {
         /* add '/' at the end of the directory name if not already there */
 #endif
       {
         /* add '/' at the end of the directory name if not already there */
-        int len = safe_strlen (LastDir);
+        int len = str_len (LastDir);
 
         if (len && LastDir[len - 1] != '/' && sizeof (buf) > len)
           buf[len] = '/';
 
         if (len && LastDir[len - 1] != '/' && sizeof (buf) > len)
           buf[len] = '/';
@@ -1133,7 +1138,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
         buffy = 0;
         mutt_expand_path (buf, sizeof (buf));
 #ifdef USE_IMAP
         buffy = 0;
         mutt_expand_path (buf, sizeof (buf));
 #ifdef USE_IMAP
-        if (mx_is_imap (buf)) {
+        if (imap_is_magic (buf, NULL) == M_IMAP) {
           strfcpy (LastDir, buf, sizeof (LastDir));
           destroy_state (&state);
           init_state (&state, NULL);
           strfcpy (LastDir, buf, sizeof (LastDir));
           destroy_state (&state);
           init_state (&state, NULL);
@@ -1176,7 +1181,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
 
       strfcpy (buf, NONULL (Mask.pattern), sizeof (buf));
       if (mutt_get_field (_("File Mask: "), buf, sizeof (buf), 0) == 0) {
 
       strfcpy (buf, NONULL (Mask.pattern), sizeof (buf));
       if (mutt_get_field (_("File Mask: "), buf, sizeof (buf), 0) == 0) {
-        regex_t *rx = (regex_t *) safe_malloc (sizeof (regex_t));
+        regex_t *rx = (regex_t *) mem_malloc (sizeof (regex_t));
         char *s = buf;
         int not = 0, err;
 
         char *s = buf;
         int not = 0, err;
 
@@ -1194,13 +1199,13 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
         if ((err = REGCOMP (rx, s, REG_NOSUB)) != 0) {
           regerror (err, rx, buf, sizeof (buf));
           regfree (rx);
         if ((err = REGCOMP (rx, s, REG_NOSUB)) != 0) {
           regerror (err, rx, buf, sizeof (buf));
           regfree (rx);
-          FREE (&rx);
+          mem_free (&rx);
           mutt_error ("%s", buf);
         }
         else {
           str_replace (&Mask.pattern, buf);
           regfree (Mask.rx);
           mutt_error ("%s", buf);
         }
         else {
           str_replace (&Mask.pattern, buf);
           regfree (Mask.rx);
-          FREE (&Mask.rx);
+          mem_free (&Mask.rx);
           Mask.rx = rx;
           Mask.not = not;
 
           Mask.rx = rx;
           Mask.not = not;
 
@@ -1290,7 +1295,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
           goto bail;
       }
 #ifdef USE_IMAP
           goto bail;
       }
 #ifdef USE_IMAP
-      else if (mx_is_imap (LastDir)) {
+      else if (imap_is_magic (LastDir, NULL) == M_IMAP) {
         init_state (&state, NULL);
         state.imap_browse = 1;
         imap_browse (LastDir, &state);
         init_state (&state, NULL);
         state.imap_browse = 1;
         imap_browse (LastDir, &state);
@@ -1303,7 +1308,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
       break;
 
     case OP_BUFFY_LIST:
       break;
 
     case OP_BUFFY_LIST:
-      mutt_buffy_list ();
+      buffy_list ();
       break;
 
     case OP_BROWSER_NEW_FILE:
       break;
 
     case OP_BROWSER_NEW_FILE:
@@ -1381,11 +1386,11 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
            folder.ff->st = NULL;
            folder.ff->is_new = nd->new;
            folder.ff->nd = nd;
            folder.ff->st = NULL;
            folder.ff->is_new = nd->new;
            folder.ff->nd = nd;
-           FREE (&f->desc);
+           mem_free (&f->desc);
            mutt_FormatString (buffer, sizeof (buffer), NONULL(GroupFormat),
                  newsgroup_format_str, (unsigned long) &folder,
                  M_FORMAT_ARROWCURSOR);
            mutt_FormatString (buffer, sizeof (buffer), NONULL(GroupFormat),
                  newsgroup_format_str, (unsigned long) &folder,
                  M_FORMAT_ARROWCURSOR);
-           f->desc = safe_strdup (buffer); */
+           f->desc = str_dup (buffer); */
           if (menu->current + 1 < menu->max)
             menu->current++;
           menu->redraw = REDRAW_MOTION_RESYNCH;
           if (menu->current + 1 < menu->max)
             menu->current++;
           menu->redraw = REDRAW_MOTION_RESYNCH;
@@ -1425,7 +1430,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
     case OP_SUBSCRIBE_PATTERN:
     case OP_UNSUBSCRIBE_PATTERN:
       if (option (OPTNEWS)) {
     case OP_SUBSCRIBE_PATTERN:
     case OP_UNSUBSCRIBE_PATTERN:
       if (option (OPTNEWS)) {
-        regex_t *rx = (regex_t *) safe_malloc (sizeof (regex_t));
+        regex_t *rx = (regex_t *) mem_malloc (sizeof (regex_t));
         char *s = buf;
         int j = menu->current;
         NNTP_DATA *nd;
         char *s = buf;
         int j = menu->current;
         NNTP_DATA *nd;
@@ -1441,14 +1446,14 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
           else
             snprintf (tmp, sizeof (tmp), _("Unsubscribe pattern: "));
           if (mutt_get_field (tmp, buf, sizeof (buf), 0) != 0 || !buf[0]) {
           else
             snprintf (tmp, sizeof (tmp), _("Unsubscribe pattern: "));
           if (mutt_get_field (tmp, buf, sizeof (buf), 0) != 0 || !buf[0]) {
-            FREE (&rx);
+            mem_free (&rx);
             break;
           }
 
           if ((err = REGCOMP (rx, s, REG_NOSUB)) != 0) {
             regerror (err, rx, buf, sizeof (buf));
             regfree (rx);
             break;
           }
 
           if ((err = REGCOMP (rx, s, REG_NOSUB)) != 0) {
             regerror (err, rx, buf, sizeof (buf));
             regfree (rx);
-            FREE (&rx);
+            mem_free (&rx);
             mutt_error ("%s", buf);
             break;
           }
             mutt_error ("%s", buf);
             break;
           }
@@ -1479,11 +1484,11 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
                folder.f = NULL;
                folder.new = nd->new;
                folder.nd = nd;
                folder.f = NULL;
                folder.new = nd->new;
                folder.nd = nd;
-               FREE (&f->desc);
+               mem_free (&f->desc);
                mutt_FormatString (buffer, sizeof (buffer), NONULL(GroupFormat),
                        newsgroup_format_str, (unsigned long) &folder,
                        M_FORMAT_ARROWCURSOR);
                mutt_FormatString (buffer, sizeof (buffer), NONULL(GroupFormat),
                        newsgroup_format_str, (unsigned long) &folder,
                        M_FORMAT_ARROWCURSOR);
-               f->desc = safe_strdup (buffer);
+               f->desc = str_dup (buffer);
              } */
           }
           if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE) {
              } */
           }
           if (i == OP_BROWSER_SUBSCRIBE || i == OP_BROWSER_UNSUBSCRIBE) {
@@ -1513,7 +1518,7 @@ void _mutt_select_file (char *f, size_t flen, int flags, char ***files,
         nntp_clear_cacheindex (news);
         if (i != OP_BROWSER_SUBSCRIBE && i != OP_BROWSER_UNSUBSCRIBE)
           regfree (rx);
         nntp_clear_cacheindex (news);
         if (i != OP_BROWSER_SUBSCRIBE && i != OP_BROWSER_UNSUBSCRIBE)
           regfree (rx);
-        FREE (&rx);
+        mem_free (&rx);
       }
 #ifdef USE_IMAP
       else
       }
 #ifdef USE_IMAP
       else