Skip to content
  • Allison Karlitskaya's avatar
    Change semantics of seek on memory output stream · fdc5cd8d
    Allison Karlitskaya authored
    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
    fdc5cd8d