}
static void appendi (long i) {
- char buf[40];
- int n;
-
- sprintf (buf, "%ld", i);
- n = strlen (buf) + 1;
+ int n = snprintf(NULL, 0, "%ld", i) + 1;
if (sbufi + n > sbufn)
growsbuf (n);
- strcpy (&sbufp[sbufi], buf);
+ sprintf(&sbufp[sbufi], "%ld", i);
sbufi += (n - 1);
}
static void appendd (double d) {
- char buf[40];
- int n;
-
- sprintf (buf, "%lf", d);
- n = strlen (buf) + 1;
+ int n = snprintf(NULL, 0, "%lf", d) + 1;
if (sbufi + n > sbufn)
growsbuf (n);
- strcpy (&sbufp[sbufi], buf);
+ sprintf(&sbufp[sbufi], "%lf", d);
sbufi += (n - 1);
}