17 vwarnx(const char *err
, const char *fmt
, va_list args
)
19 fprintf(stderr
, "%s: ", progname
);
21 vfprintf(stderr
, fmt
, args
);
22 if (err
) fprintf(stderr
, ": %s", err
);
28 warn(const char *fmt
, ...)
30 char *err
= strerror(errno
); /* must be done first thing */
34 vwarnx(err
, fmt
, args
);
39 warnx(const char *fmt
, ...)
43 vwarnx(NULL
, fmt
, args
);
49 fmtalloc(char *fmt
, ...)
55 // find out how much space is needed
57 n
= vsnprintf(0, 0, fmt
, ap
) + 1; // include space for trailing NUL
63 vsnprintf(buf
, n
, fmt
, ap
);
70 // Zalloc allocates n bytes of zeroed memory and
71 // returns a pointer to it.
72 // If insufficient memory is available, zalloc returns 0.