From: Ralph Corderoy Date: Tue, 18 Oct 2016 15:22:41 +0000 (+0100) Subject: Shrink the static char[] for "%d" from 8KiB to just right. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/e9d39f548915dfaeb5dee56dd3bf0d9d81bf9780?ds=sidebyside;hp=353379e5a18ec6707750639e19156bbac1c8d8ce Shrink the static char[] for "%d" from 8KiB to just right. --- diff --git a/sbr/m_name.c b/sbr/m_name.c index 18ee081c..2289e82d 100644 --- a/sbr/m_name.c +++ b/sbr/m_name.c @@ -7,17 +7,21 @@ * complete copyright information. */ +#include #include -static char name[BUFSIZ]; - +#define STR(s) #s +#define SIZE(n) (sizeof STR(n)) /* Includes NUL. */ char * m_name (int num) { + static char name[SIZE(INT_MAX)]; + if (num <= 0) return "?"; - snprintf (name, sizeof(name), "%d", num); + sprintf(name, "%d", num); + return name; }