- static size_t have;
- static char *buf;
-
- int n;
- size_t want = (screen_lines + 1) * 4;
-
- if (have < want)
- buf = typeMalloc(char, have = want);
-
- (void) strcpy(buf, "virt");
- for (n = 0; n < screen_lines; n++)
- (void) sprintf(buf + strlen(buf), " %02d", OLDNUM(n));
- TR(TRACE_UPDATE | TRACE_MOVE, (buf));
-#if NO_LEAKS
- free(buf);
- have = 0;
-#endif
+ char *buf = 0;
+ size_t want = ((size_t) screen_lines(SP_PARM) + 1) * 4;
+ (void) SP_PARM;
+
+ if ((buf = typeMalloc(char, want)) != 0) {
+ int n;
+
+ *buf = '\0';
+ for (n = 0; n < screen_lines(SP_PARM); n++)
+ _nc_SPRINTF(buf + strlen(buf),
+ _nc_SLIMIT(want - strlen(buf))
+ " %02d", OLDNUM(SP_PARM, n));
+ TR(TRACE_UPDATE | TRACE_MOVE, ("virt %s", buf));
+ free(buf);
+ }