diff options
| author | Lioncache <mai.iam2048@gmail.com> | 2023-12-18 10:20:26 -0500 |
|---|---|---|
| committer | Lioncache <mai.iam2048@gmail.com> | 2023-12-18 13:08:57 -0500 |
| commit | 62740d97a83b6035e1c783b9cf9ae786e358b4ee (patch) | |
| tree | dc6e4b21e72b9b81a4cbbe4fd40734c6058a6689 /Source/Core | |
| parent | 9abcc1c08b6f51a7dead69523dfc86ba115d8f86 (diff) | |
Core/DSP/DSPTables: Make use of fmt::format in pdname()
Resolves a deprecation warning on macOS. Also, we can convert
the function to just return a std::string instead of using a
static internal buffer, which is gross and thread-unsafe.
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/Core/DSP/DSPTables.cpp | 9 | ||||
| -rw-r--r-- | Source/Core/Core/DSP/DSPTables.h | 2 |
2 files changed, 5 insertions, 6 deletions
diff --git a/Source/Core/Core/DSP/DSPTables.cpp b/Source/Core/Core/DSP/DSPTables.cpp index cb8a224396..191f8b3622 100644 --- a/Source/Core/Core/DSP/DSPTables.cpp +++ b/Source/Core/Core/DSP/DSPTables.cpp @@ -10,6 +10,8 @@ #include <cstddef> #include <cstdio> +#include <fmt/format.h> + #include "Common/CommonTypes.h" #include "Common/Logging/Log.h" @@ -492,18 +494,15 @@ const std::array<pdlabel_t, 36> regnames = }}; // clang-format on -const char* pdname(u16 val) +std::string pdname(u16 val) { - static char tmpstr[12]; // nasty - for (const pdlabel_t& pdlabel : pdlabels) { if (pdlabel.addr == val) return pdlabel.name; } - sprintf(tmpstr, "0x%04x", val); - return tmpstr; + return fmt::format("0x{:04x}", val); } const char* pdregname(int val) diff --git a/Source/Core/Core/DSP/DSPTables.h b/Source/Core/Core/DSP/DSPTables.h index e2a90d8e7f..8dead3acad 100644 --- a/Source/Core/Core/DSP/DSPTables.h +++ b/Source/Core/Core/DSP/DSPTables.h @@ -93,7 +93,7 @@ struct pdlabel_t extern const std::array<pdlabel_t, 36> regnames; extern const std::array<pdlabel_t, 96> pdlabels; -const char* pdname(u16 val); +std::string pdname(u16 val); const char* pdregname(int val); const char* pdregnamelong(int val); |
