sfeed_curses

[fork] sfeed (atom feed) reader
Log | Files | Refs | README | LICENSE

commit deb68b3f057eb695c67d5e00c32faac5a20742c4
parent be541fd612f60c792cf0085549de9ed9942f1136
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Wed, 19 Aug 2020 19:29:12 +0200

getsidebarwidth(): no need for a buffer just for counting the characters

Diffstat:
Msfeed_curses.c | 6++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/sfeed_curses.c b/sfeed_curses.c @@ -1299,15 +1299,13 @@ int getsidebarwidth(void) { struct feed *feed; - static char text[1024]; int i, len, width = 0; for (i = 0; i < nfeeds; i++) { feed = &feeds[i]; - snprintf(text, sizeof(text), "%s (%lu/%lu)", - feed->name, feed->totalnew, feed->total); - len = colw(text); + len = snprintf(NULL, 0, " (%lu/%lu)", feed->totalnew, feed->total) + + colw(feed->name); if (len > width) width = len;