aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/compression.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libutil/compression.cc')
-rw-r--r--src/libutil/compression.cc13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/libutil/compression.cc b/src/libutil/compression.cc
index 773617031..5152a2146 100644
--- a/src/libutil/compression.cc
+++ b/src/libutil/compression.cc
@@ -1,3 +1,4 @@
+#include "charptr-cast.hh"
#include "compression.hh"
#include "tarfile.hh"
#include "signals.hh"
@@ -119,8 +120,8 @@ private:
static ssize_t callback_write(struct archive * archive, void * _self, const void * buffer, size_t length)
{
- auto self = (ArchiveCompressionSink *) _self;
- self->nextSink({(const char *) buffer, length});
+ auto self = static_cast<ArchiveCompressionSink *>(_self);
+ self->nextSink({static_cast<const char *>(buffer), length});
return length;
}
};
@@ -160,7 +161,7 @@ struct BrotliDecompressionSource : Source
size_t read(char * data, size_t len) override
{
- uint8_t * out = (uint8_t *) data;
+ uint8_t * out = charptr_cast<uint8_t *>(data);
const auto * begin = out;
while (len && !BrotliDecoderIsFinished(state.get())) {
@@ -172,7 +173,7 @@ struct BrotliDecompressionSource : Source
} catch (EndOfFile &) {
break;
}
- next_in = (const uint8_t *) buf.get();
+ next_in = charptr_cast<const uint8_t *>(buf.get());
}
if (!BrotliDecoderDecompressStream(
@@ -238,7 +239,7 @@ struct BrotliCompressionSink : ChunkedCompressionSink
void writeInternal(std::string_view data) override
{
- auto next_in = (const uint8_t *) data.data();
+ auto next_in = charptr_cast<const uint8_t *>(data.data());
size_t avail_in = data.size();
uint8_t * next_out = outbuf;
size_t avail_out = sizeof(outbuf);
@@ -254,7 +255,7 @@ struct BrotliCompressionSink : ChunkedCompressionSink
throw CompressionError("error while compressing brotli compression");
if (avail_out < sizeof(outbuf) || avail_in == 0) {
- nextSink({(const char *) outbuf, sizeof(outbuf) - avail_out});
+ nextSink({reinterpret_cast<const char *>(outbuf), sizeof(outbuf) - avail_out});
next_out = outbuf;
avail_out = sizeof(outbuf);
}