]> granicus.if.org Git - mutt/commitdiff
Change BUFFY->realpath to be const char *.
authorKevin McCarthy <kevin@8t8.us>
Tue, 16 Apr 2019 19:23:42 +0000 (12:23 -0700)
committerKevin McCarthy <kevin@8t8.us>
Tue, 16 Apr 2019 19:23:42 +0000 (12:23 -0700)
BUFFY->path is a fixed array (which will be converted to a BUFFER in
the next commit).  This is needed to call mutt_expand_path().

However, BUFFY->realpath has no such need, and so it is a bit
wasteful (not to mention not big enough) to store as such.

buffy.c
buffy.h

diff --git a/buffy.c b/buffy.c
index d413abf5339965aab7e8be1063c575dfb288eae9..0fef877c82bc517dadd57f82e2d586b4cf894eac 100644 (file)
--- a/buffy.c
+++ b/buffy.c
@@ -235,7 +235,7 @@ static BUFFY *buffy_new (const char *path)
   buffy = (BUFFY *) safe_calloc (1, sizeof (BUFFY));
   strfcpy (buffy->path, path, sizeof (buffy->path));
   r = realpath (path, rp);
-  strfcpy (buffy->realpath, r ? rp : path, sizeof (buffy->realpath));
+  buffy->realpath = safe_strdup (r ? rp : path);
   buffy->next = NULL;
   buffy->magic = 0;
 
@@ -244,6 +244,10 @@ static BUFFY *buffy_new (const char *path)
 
 static void buffy_free (BUFFY **mailbox)
 {
+  if (!(mailbox && *mailbox))
+    return;
+
+  FREE (&((*mailbox)->realpath));
   FREE (mailbox); /* __FREE_CHECKED__ */
 }
 
diff --git a/buffy.h b/buffy.h
index 89091c9c6f5d694eb87d8a4fe1a6d0ad4c4b54fe..e045f8fd63a2f440e640380f68ddc4d6f5e7bd9a 100644 (file)
--- a/buffy.h
+++ b/buffy.h
@@ -26,8 +26,8 @@
 typedef struct buffy_t
 {
   char path[_POSIX_PATH_MAX];
-  char realpath[_POSIX_PATH_MAX]; /* used for duplicate detection, context comparison,
-                                     and the sidebar */
+  const char *realpath; /* used for duplicate detection, context comparison,
+                           and the sidebar */
   off_t size;
   struct buffy_t *next;
   short new;                   /* mailbox has new mail */