r4580 - trunk/varnish-cache/bin/varnishd
phk at projects.linpro.no
phk at projects.linpro.no
Sun Feb 21 21:24:12 CET 2010
Author: phk
Date: 2010-02-21 21:24:11 +0100 (Sun, 21 Feb 2010)
New Revision: 4580
Modified:
trunk/varnish-cache/bin/varnishd/mgt_cli.c
Log:
Evict the last *asprintf usage.
Modified: trunk/varnish-cache/bin/varnishd/mgt_cli.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_cli.c 2010-02-21 20:15:44 UTC (rev 4579)
+++ trunk/varnish-cache/bin/varnishd/mgt_cli.c 2010-02-21 20:24:11 UTC (rev 4580)
@@ -208,10 +208,10 @@
int
mgt_cli_askchild(unsigned *status, char **resp, const char *fmt, ...) {
- char *p;
int i, j;
va_list ap;
unsigned u;
+ char buf[params->cli_buffer], *p;
if (resp != NULL)
*resp = NULL;
@@ -223,13 +223,12 @@
return (CLIS_CANT);
}
va_start(ap, fmt);
- i = vasprintf(&p, fmt, ap);
+ vbprintf(buf, fmt, ap);
va_end(ap);
- if (i < 0)
- return (i);
- assert(p[i - 1] == '\n');
- j = write(cli_o, p, i);
- free(p);
+ p = strchr(buf, '\0');
+ assert(p != NULL && p > buf && p[-1] == '\n');
+ i = p - buf;
+ j = write(cli_o, buf, i);
if (j != i) {
if (status != NULL)
*status = CLIS_COMMS;
More information about the varnish-commit
mailing list