From 418d811d18c1c536ac5c303deceda5bc13ef43c9 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sun, 26 Jul 2020 16:30:00 +0200 Subject: [PATCH] Rework of C Interface exception handler. --- CInterface/Core.cpp | 2 +- CInterface/Core.hpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CInterface/Core.cpp b/CInterface/Core.cpp index beca1ae..b12294d 100644 --- a/CInterface/Core.cpp +++ b/CInterface/Core.cpp @@ -1,4 +1,4 @@ #include "Core.hpp" -std::string ExceptionHandler::_lastException = ""; +char* ExceptionHandler::_lastException = 0; export const char* CreatureLib_C_GetLastException() { return ExceptionHandler::GetLastException(); } diff --git a/CInterface/Core.hpp b/CInterface/Core.hpp index 6616b28..fb903cd 100644 --- a/CInterface/Core.hpp +++ b/CInterface/Core.hpp @@ -9,11 +9,11 @@ #define CreatureLibException 1; class ExceptionHandler { - static std::string _lastException; + static char* _lastException; public: - static void SetLastException(const std::exception& e) { _lastException = std::string(e.what()); } - static const char* GetLastException() { return _lastException.c_str(); } + static void SetLastException(const std::exception& e) { _lastException = strcpy(_lastException, e.what()); } + static const char* GetLastException() { return _lastException; } }; #define Try(data) \