Re: [PATCH 1/4] stringbuf: A string buffer implementation

Denys Vlasenko
2007-10-30T15:26:53Z

On Tuesday 23 October 2007 22:12, Matthew Wilcox wrote:
> Consecutive calls to printk are non-atomic, which leads to various
> implementations for accumulating strings which can be printed in one call.
> This is a generic string buffer which can also be used for non-printk
> purposes. There is no sb_scanf implementation yet as I haven't identified
> a user for it.
>
> Signed-off-by: Matthew Wilcox <willy@linux.intel.com>

> +static inline void sb_free(struct stringbuf *sb)
> +{
> + if (sb->alloc > 0)
> + kfree(sb->s);
> + sb_init(sb);
> +}

> +static inline char *sb_to_string(struct stringbuf *sb)
> +{
> + char *s = sb->s;
> + if (sb_error(sb))
> + s = kstrdup(s, GFP_ATOMIC);
> + sb_init(sb);
> + return s;
> +}

I am not sure inlining these functions is a win.
--
vda