Change semantics of seek on memory output stream
authorRyan Lortie <desrt@desrt.ca>
Wed, 23 Oct 2013 15:25:56 +0000 (11:25 -0400)
committerRyan Lortie <desrt@desrt.ca>
Wed, 23 Oct 2013 15:31:27 +0000 (11:31 -0400)
commitfdc5cd8d9fcf9ac8c0ebe27cf6cd3c8648690a8b
tree14284f531a65a3b8efe19e61a2b77438897cd10d
parent38ef509cf3558bffb326f7c6d511bcd77e98981b
Change semantics of seek on memory output stream

It is our intention that memory output streams should operate in two
distinct modes, depending on if a realloc function was provided or not.

In the case that we have a realloc function (resizable mode), we want
the stream to behave as if it were a file that started out empty.  In
the case that we don't have a realloc function (fixed-sized mode), we
want the stream to behave as a block device would.

To this end, we introduce two changes in functionality:

 - seeking to SEEK_END on a resizable stream will now seek to the end of
   the valid data region, not to the end of the allocated memory (which
   is really just an implementation detail)

 - seeks past the end of the allocated memory size are now permitted,
   but only on resizable streams.  The next write will grow the buffer
   (inserting zeros between).

Some tweaks to testcases were required in order not to break the build,
which indicates that this is an API break, but it seems unlikely that
anyone will be effected by these changes 'in the real world'.

Updates to documentation and further testcases are in following commits.

Based on a patch from Maciej Piechotka <uzytkownik2@gmail.com>.

https://bugzilla.gnome.org/show_bug.cgi?id=684842
gio/gmemoryoutputstream.c
gio/tests/buffered-output-stream.c
gio/tests/memory-output-stream.c