]> granicus.if.org Git - mutt/commitdiff
Convert shrink_histfile() tempfile to use buffer pool.
authorKevin McCarthy <kevin@8t8.us>
Sat, 5 Oct 2019 06:10:04 +0000 (14:10 +0800)
committerKevin McCarthy <kevin@8t8.us>
Sat, 5 Oct 2019 06:10:04 +0000 (14:10 +0800)
history.c

index 48565fdd39bfcc6ca38db2dcefda4c66a22c07ea..f2dde193cab6968ee6f84a538c91f3d700d4fa37 100644 (file)
--- a/history.c
+++ b/history.c
@@ -188,7 +188,7 @@ static int dup_hash_inc (HASH *dup_hash, char *s)
 
 static void shrink_histfile (void)
 {
-  char tmpfname[_POSIX_PATH_MAX];
+  BUFFER *tmpfname = NULL;
   FILE *f, *tmp = NULL;
   int n[HC_LAST] = { 0 };
   int line, hclass, read;
@@ -236,10 +236,11 @@ static void shrink_histfile (void)
 
   if (regen_file)
   {
-    mutt_mktemp (tmpfname, sizeof (tmpfname));
-    if ((tmp = safe_fopen (tmpfname, "w+")) == NULL)
+    tmpfname = mutt_buffer_pool_get ();
+    mutt_buffer_mktemp (tmpfname);
+    if ((tmp = safe_fopen (mutt_b2s (tmpfname), "w+")) == NULL)
     {
-      mutt_perror (tmpfname);
+      mutt_perror (mutt_b2s (tmpfname));
       goto cleanup;
     }
     rewind (f);
@@ -277,8 +278,9 @@ cleanup:
       safe_fclose (&f);
     }
     safe_fclose (&tmp);
-    unlink (tmpfname);
+    unlink (mutt_b2s (tmpfname));
   }
+  mutt_buffer_pool_release (&tmpfname);
   if (option (OPTHISTREMOVEDUPS))
     for (hclass = 0; hclass < HC_LAST; hclass++)
       hash_destroy (&dup_hashes[hclass], NULL);