From 1e0a52b03fe655d7073ef20703dbb2e7646f74d3 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Wed, 23 Oct 2024 19:16:19 +0200 Subject: add XY struct for 2d points and offsets --- Exception.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'Exception.cpp') 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(static_cast(malloc(sz))); + + vsnprintf(this->error.get(), sz, fmt, args); } Exception::Exception(const char * fmt, ...) { -- cgit v1.2.3