From f2b48bad79811949d4c8dd15cb708b4d5624e893 Mon Sep 17 00:00:00 2001 From: Rubidium Date: Sat, 10 May 2025 23:16:29 +0200 Subject: [PATCH] Codechange: remove last (hidden) users of memset --- src/os/windows/string_uniscribe.cpp | 9 +++------ src/safeguards.h | 1 + 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/os/windows/string_uniscribe.cpp b/src/os/windows/string_uniscribe.cpp index 9ba43d5bdd..210e7a17f0 100644 --- a/src/os/windows/string_uniscribe.cpp +++ b/src/os/windows/string_uniscribe.cpp @@ -143,8 +143,7 @@ static HFONT HFontFromFont(Font *font) { if (font->fc->GetOSHandle() != nullptr) return CreateFontIndirect(reinterpret_cast(const_cast(font->fc->GetOSHandle()))); - LOGFONT logfont; - ZeroMemory(&logfont, sizeof(LOGFONT)); + LOGFONT logfont{}; logfont.lfHeight = font->fc->GetHeight(); logfont.lfWeight = FW_NORMAL; logfont.lfCharSet = DEFAULT_CHARSET; @@ -249,12 +248,10 @@ static bool UniscribeShapeRun(const UniscribeParagraphLayoutFactory::CharType *b static std::vector UniscribeItemizeString(UniscribeParagraphLayoutFactory::CharType *buff, int32_t length) { /* Itemize text. */ - SCRIPT_CONTROL control; - ZeroMemory(&control, sizeof(SCRIPT_CONTROL)); + SCRIPT_CONTROL control{}; control.uDefaultLanguage = _current_language->winlangid; - SCRIPT_STATE state; - ZeroMemory(&state, sizeof(SCRIPT_STATE)); + SCRIPT_STATE state{}; state.uBidiLevel = _current_text_dir == TD_RTL ? 1 : 0; std::vector items(16); diff --git a/src/safeguards.h b/src/safeguards.h index 91157590a7..97c2bc6c45 100644 --- a/src/safeguards.h +++ b/src/safeguards.h @@ -49,6 +49,7 @@ #define memcmp SAFEGUARD_DO_NOT_USE_THIS_METHOD #define memcpy SAFEGUARD_DO_NOT_USE_THIS_METHOD +#define memset SAFEGUARD_DO_NOT_USE_THIS_METHOD /* Use fgets instead. */ #define gets SAFEGUARD_DO_NOT_USE_THIS_METHOD