io/Reader: use std::span

This commit is contained in:
Max Kellermann
2023-10-05 10:25:16 +02:00
parent b9704715fb
commit 7ccc4ddf0d
19 changed files with 52 additions and 51 deletions

View File

@@ -4,10 +4,10 @@
#include "Reader.hxx"
#include "InputStream.hxx"
size_t
InputStreamReader::Read(void *data, size_t size)
std::size_t
InputStreamReader::Read(std::span<std::byte> dest)
{
size_t nbytes = is.LockRead(data, size);
size_t nbytes = is.LockRead(dest.data(), dest.size());
assert(nbytes > 0 || is.IsEOF());
return nbytes;

View File

@@ -20,7 +20,7 @@ public:
:is(_is) {}
/* virtual methods from class Reader */
size_t Read(void *data, size_t size) override;
std::size_t Read(std::span<std::byte> dest) override;
};
#endif

View File

@@ -78,7 +78,7 @@ FileInputStream::Read(std::unique_lock<Mutex> &,
{
const ScopeUnlock unlock(mutex);
nbytes = reader.Read(ptr, read_size);
nbytes = reader.Read({static_cast<std::byte *>(ptr), read_size});
}
if (nbytes == 0 && !IsEOF())