mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:47:35 +00:00
LibGfx: Remove reckless PNGChunk::add(T) method
This method added function using host byte order, which is never what we want. In practice, it was fine because it was only called from add_u8() (which is just 1 byte large) and add_as_big_endian() (since that did endian swapping before calling the method). But the method doesn't really help any and is dangerous, so remove it. No behavior change.
This commit is contained in:
parent
6a8c8aae9b
commit
1a03f45a73
1 changed files with 3 additions and 13 deletions
|
@ -41,9 +41,6 @@ public:
|
|||
u32 crc();
|
||||
|
||||
private:
|
||||
template<Unsigned T>
|
||||
ErrorOr<void> add(T);
|
||||
|
||||
ByteBuffer m_data;
|
||||
DeprecatedString m_type;
|
||||
};
|
||||
|
@ -52,7 +49,7 @@ PNGChunk::PNGChunk(DeprecatedString type)
|
|||
: m_type(move(type))
|
||||
{
|
||||
// NOTE: These are MUST() because they should always be able to fit in m_data's inline capacity.
|
||||
MUST(add<data_length_type>(0));
|
||||
MUST(add_as_big_endian<data_length_type>(0));
|
||||
MUST(store_type());
|
||||
}
|
||||
|
||||
|
@ -74,13 +71,6 @@ u32 PNGChunk::crc()
|
|||
return crc;
|
||||
}
|
||||
|
||||
template<Unsigned T>
|
||||
ErrorOr<void> PNGChunk::add(T data)
|
||||
{
|
||||
TRY(m_data.try_append(&data, sizeof(T)));
|
||||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<void> PNGChunk::compress_and_add(ReadonlyBytes uncompressed_bytes)
|
||||
{
|
||||
return add(TRY(Compress::ZlibCompressor::compress_all(uncompressed_bytes, Compress::ZlibCompressionLevel::Best)));
|
||||
|
@ -96,13 +86,13 @@ template<typename T>
|
|||
ErrorOr<void> PNGChunk::add_as_big_endian(T data)
|
||||
{
|
||||
auto data_out = AK::convert_between_host_and_big_endian(data);
|
||||
TRY(add(data_out));
|
||||
TRY(m_data.try_append(&data_out, sizeof(T)));
|
||||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<void> PNGChunk::add_u8(u8 data)
|
||||
{
|
||||
TRY(add(data));
|
||||
TRY(m_data.try_append(data));
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue