aboutsummaryrefslogtreecommitdiff
path: root/Exception.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Exception.cpp')
-rw-r--r--Exception.cpp14
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, ...) {