From 36e99e95a2a0d4f6a579236c44fe2c231b714a73 Mon Sep 17 00:00:00 2001 From: Maschell Date: Sun, 5 Nov 2023 13:31:22 +0100 Subject: [PATCH] Update PluginInformation to return std::optional instead of raw pointer --- source/plugin/PluginInformation.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/source/plugin/PluginInformation.h b/source/plugin/PluginInformation.h index ee2a8f2..4282553 100644 --- a/source/plugin/PluginInformation.h +++ b/source/plugin/PluginInformation.h @@ -78,11 +78,11 @@ public: return mSectionInfoList; } - [[nodiscard]] SectionInfo *getSectionInfo(const std::string §ionName) const { + [[nodiscard]] std::optional getSectionInfo(const std::string §ionName) const { if (getSectionInfoList().contains(sectionName)) { - return mSectionInfoList.at(sectionName).get(); + return *mSectionInfoList.at(sectionName); } - return nullptr; + return std::nullopt; } void setTrampolineId(uint8_t trampolineId) { @@ -93,7 +93,7 @@ public: return mTrampolineId; } - [[nodiscard]] FunctionSymbolData *getNearestFunctionSymbolData(uint32_t address) const { + [[nodiscard]] std::optional getNearestFunctionSymbolData(uint32_t address) const { FunctionSymbolData *result = nullptr; bool foundHit = false; @@ -106,8 +106,11 @@ public: foundHit = true; } } + if (!foundHit) { + return std::nullopt; + } - return result; + return *result; } [[nodiscard]] const HeapMemoryFixedSize &getTextMemory() const {