#include <u.h>
#include <libc.h>
#include <thread.h>

int
chanprint(Channel *c, char *fmt, ...)
{
	va_list arg;
	char *buf;
	enum {NBUF=1024};
	int n;

	buf = malloc(NBUF);
	if(buf == nil)
		sysfatal("malloc failed: %r");
	va_start(arg, fmt);
	doprint(buf, buf+NBUF, fmt, arg);
	va_end(arg);
	n = sendp(c, buf);
	yield();	/* let recipient handle message immediately */
	return n;
}


syntax highlighted by Code2HTML, v. 0.9.1