diff options
author | Andreas Kling <kling@serenityos.org> | 2021-07-21 22:09:40 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-07-22 09:17:01 +0200 |
commit | e4c15140337b483c1007ecd16f5f3f08c812d3f3 (patch) | |
tree | 09a2e2fea6a6255cdb1e349c05829d266b2a31eb /Userland/Libraries/LibGfx | |
parent | 027bfc4effdae933d9f329810cb375b18eb7aeac (diff) | |
download | serenity-e4c15140337b483c1007ecd16f5f3f08c812d3f3.zip |
LibGfx: Use calloc() instead of malloc()+memset() Gfx::BitmapFont
Diffstat (limited to 'Userland/Libraries/LibGfx')
-rw-r--r-- | Userland/Libraries/LibGfx/BitmapFont.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/Userland/Libraries/LibGfx/BitmapFont.cpp b/Userland/Libraries/LibGfx/BitmapFont.cpp index 6a83542113..d24316ddc9 100644 --- a/Userland/Libraries/LibGfx/BitmapFont.cpp +++ b/Userland/Libraries/LibGfx/BitmapFont.cpp @@ -45,10 +45,8 @@ NonnullRefPtr<BitmapFont> BitmapFont::create(u8 glyph_height, u8 glyph_width, bo { size_t bytes_per_glyph = sizeof(u32) * glyph_height; size_t count = glyph_count_by_type(type); - auto* new_rows = static_cast<unsigned*>(malloc(bytes_per_glyph * count)); - memset(new_rows, 0, bytes_per_glyph * count); - auto* new_widths = static_cast<u8*>(malloc(count)); - memset(new_widths, 0, count); + auto* new_rows = static_cast<unsigned*>(calloc(count, bytes_per_glyph)); + auto* new_widths = static_cast<u8*>(calloc(count, 1)); return adopt_ref(*new BitmapFont("Untitled", "Untitled", new_rows, new_widths, fixed, glyph_width, glyph_height, 1, type, 0, 0, 0, 400, true)); } @@ -295,12 +293,10 @@ void BitmapFont::set_type(FontTypes type) size_t bytes_per_glyph = sizeof(u32) * glyph_height(); - auto* new_rows = static_cast<unsigned*>(kmalloc(bytes_per_glyph * new_glyph_count)); - memset(new_rows, (unsigned)0, bytes_per_glyph * new_glyph_count); + auto* new_rows = static_cast<unsigned*>(calloc(new_glyph_count, bytes_per_glyph)); memcpy(new_rows, m_rows, bytes_per_glyph * item_count_to_copy); - auto* new_widths = static_cast<u8*>(kmalloc(new_glyph_count)); - memset(new_widths, (u8)0, new_glyph_count); + auto* new_widths = static_cast<u8*>(calloc(new_glyph_count, 1)); memcpy(new_widths, m_glyph_widths, item_count_to_copy); kfree(m_rows); |