Re: [PATCH 1/3] fs: seq_file: add seq_reserve

From: Colin Cross
Date: Thu Sep 22 2011 - 19:24:33 EST


On Thu, Sep 22, 2011 at 3:54 PM, Alan Cox <alan@xxxxxxxxxxxxxxxxxxx> wrote:
> On Thu, 22 Sep 2011 13:57:07 -0700
> Colin Cross <ccross@xxxxxxxxxxx> wrote:
>
>> Adds a seq_reserve function to allow users of the seq_file interface to
>> increase the initial size of the buffer.  Avoids repeated allocations and
>> calls to the show function in cases where large buffers of known size are
>> needed.
>
> Would it not be better to have something akin to
>
>
>        void seq_set_buffer(struct seq_file *m, void *ptr, size_t size)
>        {
>                m->buf = ptr;
>                m->size = size;
>                m->private = 1;
>        }
>
> and let the caller simply provide a buffer by any means it wishes (even
> statically) and free it again itself. That keeps the caller fully in
> control when it wishes to be.

What would happen when seq_read overflowed the buffer? It wouldn't be
able to reallocate it.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/