Prohibit use of malloc

This commit is contained in:
Chris Thrasher 2024-04-27 06:11:41 +00:00
parent eb9c84309f
commit 1d95c65526
2 changed files with 2 additions and 1 deletions

View File

@ -35,7 +35,6 @@ Checks: >
-cppcoreguidelines-macro-to-enum, -cppcoreguidelines-macro-to-enum,
-cppcoreguidelines-macro-usage, -cppcoreguidelines-macro-usage,
-cppcoreguidelines-narrowing-conversions, -cppcoreguidelines-narrowing-conversions,
-cppcoreguidelines-no-malloc,
-cppcoreguidelines-non-private-member-variables-in-classes, -cppcoreguidelines-non-private-member-variables-in-classes,
-cppcoreguidelines-owning-memory, -cppcoreguidelines-owning-memory,
-cppcoreguidelines-prefer-member-initializer, -cppcoreguidelines-prefer-member-initializer,

View File

@ -957,8 +957,10 @@ void WindowImplX11::setIcon(const Vector2u& size, const std::uint8_t* pixels)
{ {
// X11 wants BGRA pixels: swap red and blue channels // X11 wants BGRA pixels: swap red and blue channels
// Note: this memory will be freed by X11Ptr<XImage> deleter // Note: this memory will be freed by X11Ptr<XImage> deleter
// NOLINTBEGIN(cppcoreguidelines-no-malloc)
auto* iconPixels = static_cast<std::uint8_t*>( auto* iconPixels = static_cast<std::uint8_t*>(
std::malloc(static_cast<std::size_t>(size.x) * static_cast<std::size_t>(size.y) * 4)); std::malloc(static_cast<std::size_t>(size.x) * static_cast<std::size_t>(size.y) * 4));
// NOLINTEND(cppcoreguidelines-no-malloc)
for (std::size_t i = 0; i < static_cast<std::size_t>(size.x) * static_cast<std::size_t>(size.y); ++i) for (std::size_t i = 0; i < static_cast<std::size_t>(size.x) * static_cast<std::size_t>(size.y); ++i)
{ {
iconPixels[i * 4 + 0] = pixels[i * 4 + 2]; iconPixels[i * 4 + 0] = pixels[i * 4 + 2];