From: Kevin McCarthy Date: Tue, 16 Apr 2019 19:23:42 +0000 (-0700) Subject: Change BUFFY->realpath to be const char *. X-Git-Tag: mutt-1-12-rel~60 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6317a30369ef23b8e1b5e87692b93aa7bb9d1aaf;p=mutt Change BUFFY->realpath to be const char *. 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. --- diff --git a/buffy.c b/buffy.c index d413abf5..0fef877c 100644 --- 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 89091c9c..e045f8fd 100644 --- 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 */