1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 18:17:45 +00:00

LibTTF: Memory map TTF fonts instead of reading them into heap memory

All GUI applications currently load all TTF fonts on startup
(to populate the Gfx::FontDatabase. This could probably be smarter.)

Before this patch, everyone would open the files and read them into
heap-allocated storage. Now we simply mmap() them instead. :^)
This commit is contained in:
Andreas Kling 2021-07-04 20:21:24 +02:00
parent 560109bd42
commit 49d0b9e808
3 changed files with 25 additions and 21 deletions

View file

@ -8,9 +8,8 @@
#include <stddef.h>
#include <stdint.h>
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
extern "C" int LLVMFuzzerTestOneInput(u8 const* data, size_t size)
{
ByteBuffer font_data = ByteBuffer::copy(data, size);
(void)TTF::Font::try_load_from_memory(font_data);
(void)TTF::Font::try_load_from_externally_owned_memory({ data, size });
return 0;
}