commit e8db390d6fd1250dc5a4158f65035a2d1ce6af31
parent 0c1bf429e8e9ec622617b59b96771a90647d36ec
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Sat, 13 Mar 2021 11:25:21 +0100
tweaks: reshuffle a fragment of code, to prepare for the next change
Also, don't reserve MAXCHARLEN bytes for the terminating NUL byte.
Diffstat:
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/src/winio.c b/src/winio.c
@@ -2223,6 +2223,12 @@ void statusline(message_type importance, const char *msg, ...)
if (importance < lastmessage && lastmessage > NOTICE)
return;
+ /* Construct the message out of all the arguments. */
+ compound = nmalloc(MAXCHARLEN * COLS + 1);
+ va_start(ap, msg);
+ vsnprintf(compound, MAXCHARLEN * COLS + 1, msg, ap);
+ va_end(ap);
+
/* If there are multiple alert messages, add trailing dots to the first. */
if (lastmessage == ALERT) {
if (start_col > 4) {
@@ -2235,6 +2241,7 @@ void statusline(message_type importance, const char *msg, ...)
napms(100);
beep();
}
+ free(compound);
return;
}
@@ -2251,11 +2258,6 @@ void statusline(message_type importance, const char *msg, ...)
blank_statusbar();
- /* Construct the message out of all the arguments. */
- compound = nmalloc(MAXCHARLEN * (COLS + 1));
- va_start(ap, msg);
- vsnprintf(compound, MAXCHARLEN * (COLS + 1), msg, ap);
- va_end(ap);
message = display_string(compound, 0, COLS, FALSE, FALSE);
free(compound);
@@ -2267,7 +2269,6 @@ void statusline(message_type importance, const char *msg, ...)
if (bracketed)
waddstr(bottomwin, "[ ");
waddstr(bottomwin, message);
- free(message);
if (bracketed)
waddstr(bottomwin, " ]");
wattroff(bottomwin, colorpair);
@@ -2280,6 +2281,7 @@ void statusline(message_type importance, const char *msg, ...)
/* Push the message to the screen straightaway. */
wrefresh(bottomwin);
+ free(message);
#ifndef NANO_TINY
if (old_whitespace)