util/CircularBuffer: use std::span

This commit is contained in:
Max Kellermann
2022-05-20 10:59:53 +02:00
parent b37c031fd1
commit b50173ae8b
6 changed files with 51 additions and 55 deletions

View File

@@ -93,7 +93,7 @@ ThreadInputStream::ThreadFunc() noexcept
try {
const ScopeUnlock unlock(mutex);
nbytes = ThreadRead(w.data, w.size);
nbytes = ThreadRead(w.data(), w.size());
} catch (...) {
postponed_exception = std::current_exception();
InvokeOnAvailable();
@@ -145,8 +145,8 @@ ThreadInputStream::Read(std::unique_lock<Mutex> &lock,
auto r = buffer.Read();
if (!r.empty()) {
size_t nbytes = std::min(read_size, r.size);
memcpy(ptr, r.data, nbytes);
size_t nbytes = std::min(read_size, r.size());
memcpy(ptr, r.data(), nbytes);
buffer.Consume(nbytes);
wake_cond.notify_all();
offset += nbytes;