]> diplodocus.org Git - nmh/commitdiff
Shrink the static char[] for "%d" from 8KiB to just right.
authorRalph Corderoy <ralph@inputplus.co.uk>
Tue, 18 Oct 2016 15:22:41 +0000 (16:22 +0100)
committerRalph Corderoy <ralph@inputplus.co.uk>
Tue, 18 Oct 2016 15:22:41 +0000 (16:22 +0100)
sbr/m_name.c

index 18ee081c9e659638f61d9f28cd196d60dfe10ab3..2289e82da7251b08209c3a274d0d1758aeb1689d 100644 (file)
@@ -7,17 +7,21 @@
  * complete copyright information.
  */
 
  * complete copyright information.
  */
 
+#include <limits.h>
 #include <h/mh.h>
 
 #include <h/mh.h>
 
-static char name[BUFSIZ];
-
+#define STR(s) #s
+#define SIZE(n) (sizeof STR(n)) /* Includes NUL. */
 
 char *
 m_name (int num)
 {
 
 char *
 m_name (int num)
 {
+    static char name[SIZE(INT_MAX)];
+
     if (num <= 0)
        return "?";
 
     if (num <= 0)
        return "?";
 
-    snprintf (name, sizeof(name), "%d", num);
+    sprintf(name, "%d", num);
+
     return name;
 }
     return name;
 }