]> granicus.if.org Git - neomutt/commitdiff
Convert imap_open_new_message() to use buffer pool
authorKevin McCarthy <kevin@8t8.us>
Mon, 7 Oct 2019 01:55:39 +0000 (09:55 +0800)
committerRichard Russon <rich@flatcap.org>
Tue, 8 Oct 2019 16:43:58 +0000 (17:43 +0100)
Co-authored-by: Richard Russon <rich@flatcap.org>
imap/imap.c

index 850470afe46cabfd0f217cb7dafbcc0fdb99711f..b3f746eb8496dfe68c0b827806db58124f1337bb 100644 (file)
@@ -2247,17 +2247,24 @@ static int imap_mbox_close(struct Mailbox *m)
  */
 static int imap_msg_open_new(struct Mailbox *m, struct Message *msg, struct Email *e)
 {
-  char tmp[PATH_MAX];
+  int rc = -1;
 
-  mutt_mktemp(tmp, sizeof(tmp));
-  msg->fp = mutt_file_fopen(tmp, "w");
+  struct Buffer *tmp = mutt_buffer_pool_get();
+  mutt_buffer_mktemp(tmp);
+
+  msg->fp = mutt_file_fopen(mutt_b2s(tmp), "w");
   if (!msg->fp)
   {
-    mutt_perror(tmp);
-    return -1;
+    mutt_perror(mutt_b2s(tmp));
+    goto cleanup;
   }
-  msg->path = mutt_str_strdup(tmp);
-  return 0;
+
+  msg->path = mutt_str_strdup(mutt_b2s(tmp));
+  rc = 0;
+
+cleanup:
+  mutt_buffer_pool_release(&tmp);
+  return rc;
 }
 
 /**