Skip to content

Commit

Permalink
lib: Fix ostream-buffer to return buffer contents size in o_stream_ge…
Browse files Browse the repository at this point in the history
…t_buffer_used_size().

This is necessary for querying o_stream_get_buffer_avail_size() with respect to a limit set earlier using o_stream_set_max_buffer_size().
This is mainly useful for test suites.
  • Loading branch information
stephanbosch authored and GitLab committed Jun 16, 2017
1 parent b84eff6 commit 176fd2c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/lib/ostream-buffer.c
Expand Up @@ -53,6 +53,14 @@ o_stream_buffer_sendv(struct ostream_private *stream,
return ret;
}

static size_t
o_stream_buffer_get_used_size(const struct ostream_private *stream)
{
struct buffer_ostream *bstream = (struct buffer_ostream *)stream;

return bstream->buf->used;
}

struct ostream *o_stream_create_buffer(buffer_t *buf)
{
struct buffer_ostream *bstream;
Expand All @@ -66,6 +74,7 @@ struct ostream *o_stream_create_buffer(buffer_t *buf)
bstream->ostream.seek = o_stream_buffer_seek;
bstream->ostream.sendv = o_stream_buffer_sendv;
bstream->ostream.write_at = o_stream_buffer_write_at;
bstream->ostream.get_used_size = o_stream_buffer_get_used_size;

bstream->buf = buf;
output = o_stream_create(&bstream->ostream, NULL, -1);
Expand Down

0 comments on commit 176fd2c

Please sign in to comment.