encoder/Interface: pass std::span to Write() and Read()
This commit is contained in:
@@ -37,7 +37,6 @@
|
||||
int main(int argc, char **argv)
|
||||
try {
|
||||
const char *encoder_name;
|
||||
static char buffer[32768];
|
||||
|
||||
/* parse command line */
|
||||
|
||||
@@ -79,9 +78,10 @@ try {
|
||||
|
||||
/* do it */
|
||||
|
||||
static std::byte buffer[32768];
|
||||
ssize_t nbytes;
|
||||
while ((nbytes = read(0, buffer, sizeof(buffer))) > 0) {
|
||||
encoder->Write(buffer, nbytes);
|
||||
encoder->Write(std::span{buffer}.first(nbytes));
|
||||
EncoderToOutputStream(os, *encoder);
|
||||
}
|
||||
|
||||
|
@@ -33,8 +33,6 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
static uint8_t zero[256];
|
||||
|
||||
int
|
||||
main([[maybe_unused]] int argc, [[maybe_unused]] char **argv)
|
||||
try {
|
||||
@@ -61,7 +59,8 @@ try {
|
||||
|
||||
/* write a block of data */
|
||||
|
||||
encoder->Write(zero, sizeof(zero));
|
||||
static constexpr std::byte zero[256]{};
|
||||
encoder->Write(std::span{zero});
|
||||
|
||||
EncoderToOutputStream(os, *encoder);
|
||||
|
||||
@@ -86,7 +85,7 @@ try {
|
||||
|
||||
/* write another block of data */
|
||||
|
||||
encoder->Write(zero, sizeof(zero));
|
||||
encoder->Write(std::span{zero});
|
||||
|
||||
/* finish */
|
||||
|
||||
|
Reference in New Issue
Block a user