mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-25 08:55:11 +01:00
std: add compact_retaining, history_retain_length
This commit is contained in:
1 parent
0f91f23bb6
commit
5fb82e7d0a
33 files changed
+1088
-226
No files matched your search
@@ -102,7 +102,7 @@ Input::BringsItsOwnIOBuffer() {
|
||||
FileInput::FileInput(FILE* f) : m_f(f) {}
|
||||
|
||||
std::string //
|
||||
FileInput::CopyIn(IOBuffer* dst) {
|
||||
FileInput::CopyIn(IOBuffer* dst, uint64_t history_retain_length) {
|
||||
if (!m_f) {
|
||||
return "wuffs_aux::sync_io::FileInput: nullptr file";
|
||||
} else if (!dst) {
|
||||
@@ -110,7 +110,7 @@ FileInput::CopyIn(IOBuffer* dst) {
|
||||
} else if (dst->meta.closed) {
|
||||
return "wuffs_aux::sync_io::FileInput: end of file";
|
||||
} else {
|
||||
dst->compact();
|
||||
dst->compact_retaining(history_retain_length);
|
||||
size_t n = fread(dst->writer_pointer(), 1, dst->writer_length(), m_f);
|
||||
dst->meta.wi += n;
|
||||
dst->meta.closed = feof(m_f);
|
||||
@@ -138,7 +138,7 @@ MemoryInput::BringsItsOwnIOBuffer() {
|
||||
}
|
||||
|
||||
std::string //
|
||||
MemoryInput::CopyIn(IOBuffer* dst) {
|
||||
MemoryInput::CopyIn(IOBuffer* dst, uint64_t history_retain_length) {
|
||||
if (!dst) {
|
||||
return "wuffs_aux::sync_io::MemoryInput: nullptr IOBuffer";
|
||||
} else if (dst->meta.closed) {
|
||||
@@ -148,7 +148,7 @@ MemoryInput::CopyIn(IOBuffer* dst) {
|
||||
// to it.
|
||||
return "wuffs_aux::sync_io::MemoryInput: overlapping buffers";
|
||||
} else {
|
||||
dst->compact();
|
||||
dst->compact_retaining(history_retain_length);
|
||||
size_t nd = dst->writer_length();
|
||||
size_t ns = m_io.reader_length();
|
||||
size_t n = (nd < ns) ? nd : ns;
|
||||
@@ -203,7 +203,7 @@ AdvanceIOBufferTo(const ErrorMessages& error_messages,
|
||||
if (!input.BringsItsOwnIOBuffer()) {
|
||||
io_buf.compact();
|
||||
}
|
||||
std::string error_message = input.CopyIn(&io_buf);
|
||||
std::string error_message = input.CopyIn(&io_buf, 0);
|
||||
if (!error_message.empty()) {
|
||||
return error_message;
|
||||
}
|
||||
@@ -286,7 +286,7 @@ HandleMetadata(
|
||||
} else if (!input.BringsItsOwnIOBuffer()) {
|
||||
io_buf.compact();
|
||||
}
|
||||
std::string error_message = input.CopyIn(&io_buf);
|
||||
std::string error_message = input.CopyIn(&io_buf, 0);
|
||||
if (!error_message.empty()) {
|
||||
return error_message;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user