1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 18:18:12 +00:00

Refactor: Expose const_cast by removing ByteBuffer::warp(const void*, size_t)

This function did a const_cast internally which made the call side look
"safe". This method is removed completely and call sites are replaced
with ByteBuffer::wrap(const_cast<void*>(data), size) which makes the
behaviour obvious.
This commit is contained in:
asynts 2020-08-05 14:09:38 +02:00 committed by Andreas Kling
parent ac9f6fd1f8
commit b3d1a05261
15 changed files with 42 additions and 36 deletions

View file

@ -345,7 +345,7 @@ bool load_gif_frame_descriptors(GIFLoadingContext& context)
if (context.data_size < 32)
return false;
auto buffer = ByteBuffer::wrap(context.data, context.data_size);
auto buffer = ByteBuffer::wrap(const_cast<u8*>(context.data), context.data_size);
BufferStream stream(buffer);
Optional<GIFFormat> format = decode_gif_header(stream);
@ -546,7 +546,7 @@ GIFImageDecoderPlugin::GIFImageDecoderPlugin(const u8* data, size_t size)
m_context->data_size = size;
}
GIFImageDecoderPlugin::~GIFImageDecoderPlugin() {}
GIFImageDecoderPlugin::~GIFImageDecoderPlugin() { }
IntSize GIFImageDecoderPlugin::size()
{
@ -591,7 +591,7 @@ bool GIFImageDecoderPlugin::set_nonvolatile()
bool GIFImageDecoderPlugin::sniff()
{
auto buffer = ByteBuffer::wrap(m_context->data, m_context->data_size);
auto buffer = ByteBuffer::wrap(const_cast<u8*>(m_context->data), m_context->data_size);
BufferStream stream(buffer);
return decode_gif_header(stream).has_value();
}