diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-23 19:16:19 +0200 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-23 19:16:19 +0200 |
commit | 1e0a52b03fe655d7073ef20703dbb2e7646f74d3 (patch) | |
tree | f1709c2e9565d78c791653e71e6a4b26b3138423 /Exception.cpp | |
parent | 277157b3e06b2deeacbdbc8bf6190de19f88169d (diff) |
add XY struct for 2d points and offsets
Diffstat (limited to 'Exception.cpp')
-rw-r--r-- | Exception.cpp | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/Exception.cpp b/Exception.cpp index d9765da..423f4e9 100644 --- a/Exception.cpp +++ b/Exception.cpp @@ -4,25 +4,21 @@ #include "Exception.h" -Exception::~Exception() { - if (error != NULL) - free(error); -} +using namespace std; const char * Exception::what() { - return error; + return error.get(); } void Exception::va_format(va_list args, const char * fmt) { va_list args_copy; va_copy(args_copy, args); - size_t sz = vsnprintf(NULL, 0, fmt, args_copy) + 1; - if (error != NULL) free(error); - error = (char *) malloc(sz); va_end(args_copy); - vsnprintf(error, sz, fmt, args); + this->error = unique_ptr<char>(static_cast<char *>(malloc(sz))); + + vsnprintf(this->error.get(), sz, fmt, args); } Exception::Exception(const char * fmt, ...) { |