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,8 +4,8 @@
#include "Reader.hxx"
#include "DecoderAPI.hxx"
size_t
DecoderReader::Read(void *data, size_t size)
std::size_t
DecoderReader::Read(std::span<std::byte> dest)
{
return decoder_read(client, is, data, size);
return decoder_read(client, is, dest.data(), dest.size());
}

View File

@@ -30,7 +30,7 @@ public:
}
/* 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

@@ -60,7 +60,7 @@ static constexpr unsigned rom_size = 8192;
static void loadRom(const Path rom_path, uint8_t *dump)
{
FileReader romDump(rom_path);
if (romDump.Read(dump, rom_size) != rom_size)
if (romDump.Read(std::as_writable_bytes(std::span{dump, rom_size})) != rom_size)
throw FmtRuntimeError("Could not load rom dump '{}'", rom_path);
}