On Fri, 2007-10-26 at 12:11 +1000, Rusty Russell wrote:
Perhaps just tie stringbuf to printk and make stringbuf->buf
the same 1K size as the printk buffer?
no reallocs, no in-place out-of-memory handling
normal kzalloc and kfree of stringbuf * or add sb_alloc & sb_free
struct stringbuf {
int len;
char buf[1024];
}
/**
* sb_printf_append - append to a stringbuf
* @sb: a pointer to the stringbuf
* @fmt: printf-style format
*/
void sb_printf_append(struct stringbuf *sb, const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
sb->len += vscnprintf(&sb->buf[len], sizeof(sb->buf) - sb->len, fmt, args);
va_end(args);
}
EXPORT_SYMBOL(sb_printf_append);
-