> On Apr 5, 2024, at 2:11 AM, Johan Hattne <
hat...@g.ucla.edu> wrote:
>
> In case this is still the right forum for this sort of questions (I've searched a bit but found neither alternatives nor the answer to the question in the documention)…
>
> Is the previous buffer invalidated by a call to archive_read_data_block() that returns ARCHIVE_EOF?
Yes.
> In particular, with
>
> // Below returns ARCHIVE_OK, but yields a short read (len much smaller than block_size)
> archive_read_data_block(archive, &buf_old, &len_old, &off_old);
`archive_read_data_block` does not guarantee that it will return any particular
block size in any particular context. The amount of data returned can
vary depending on how the data was encoded in the archive.
(For example, compression can result in varying-size blocks of
data being returned.)
>
> // This returns buf_new = NULL, len_new = 0
> archive_read_data_block(archive, &buf_new, &len_new, &off_new);
>
> is it safe to use len_old bytes at buf_old at this stage?
No.
`archive_read_data_block` is always allowed to discard any previously-returned data.
(It is not _required_ to do so, but you should never rely on that.)
Tim