From c420ba349d38303b3e06880e10e150d2f1fd5c9f Mon Sep 17 00:00:00 2001 From: Rubidium Date: Thu, 1 May 2025 16:54:17 +0200 Subject: [PATCH] Codechange: use std::string_view over char* --- src/error.cpp | 2 +- src/os/windows/crashlog_win.cpp | 4 ++-- src/stdafx.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/error.cpp b/src/error.cpp index 2278391e92..9258b46039 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -16,7 +16,7 @@ FatalError("NOT_REACHED triggered at line {} of {}", location.line(), location.file_name()); } -[[noreturn]] void AssertFailedError(const char *expression, const std::source_location location) +[[noreturn]] void AssertFailedError(std::string_view expression, const std::source_location location) { FatalError("Assertion failed at line {} of {}: {}", location.line(), location.file_name(), expression); } diff --git a/src/os/windows/crashlog_win.cpp b/src/os/windows/crashlog_win.cpp index 8f22a65f78..0f609d89e2 100644 --- a/src/os/windows/crashlog_win.cpp +++ b/src/os/windows/crashlog_win.cpp @@ -260,7 +260,7 @@ static const uint MAX_FRAMES = 64; } /* Get module name. */ - const char *mod_name = "???"; + std::string_view mod_name = "???"; IMAGEHLP_MODULE64 module; module.SizeOfStruct = sizeof(module); @@ -269,7 +269,7 @@ static const uint MAX_FRAMES = 64; } /* Print module and instruction pointer. */ - std::string message = fmt::format("{:20s} {:X}", mod_name, frame.AddrPC.Offset); + std::string message = fmt::format("{:20s} {:X}", mod_name, frame.AddrPC.Offset); /* Get symbol name and line info if possible. */ DWORD64 offset; diff --git a/src/stdafx.h b/src/stdafx.h index 0f0417f0e1..f72b1ad9ee 100644 --- a/src/stdafx.h +++ b/src/stdafx.h @@ -295,7 +295,7 @@ char (&ArraySizeHelper(T (&array)[N]))[N]; #endif /* __GNUC__ || __clang__ */ [[noreturn]] void NOT_REACHED(const std::source_location location = std::source_location::current()); -[[noreturn]] void AssertFailedError(const char *expression, const std::source_location location = std::source_location::current()); +[[noreturn]] void AssertFailedError(std::string_view expression, const std::source_location location = std::source_location::current()); /* For non-debug builds with assertions enabled use the special assertion handler. */ #if defined(NDEBUG) && defined(WITH_ASSERT)