diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-30 20:52:29 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-30 20:52:29 +0100 |
commit | c45a436fc594101f676cfabe90225d825d935fec (patch) | |
tree | efc036644f49fcf9243c2e083f58d3d7b1c40f84 /frontend/Exception.cpp | |
parent | d8daa3e045ca2f41edcbed533bc5a9fef1363a17 (diff) |
clean up duplicated code
Diffstat (limited to 'frontend/Exception.cpp')
-rw-r--r-- | frontend/Exception.cpp | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/frontend/Exception.cpp b/frontend/Exception.cpp index 423f4e9..c852f0a 100644 --- a/frontend/Exception.cpp +++ b/frontend/Exception.cpp @@ -1,30 +1,22 @@ #include <cstdarg> #include <cstdio> #include <cstdlib> +#include <cstring> + +#include "backend/String.h" #include "Exception.h" using namespace std; const char * Exception::what() { - 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; - va_end(args_copy); - - this->error = unique_ptr<char>(static_cast<char *>(malloc(sz))); - - vsnprintf(this->error.get(), sz, fmt, args); + return this->error.get(); } Exception::Exception(const char * fmt, ...) { va_list args; va_start(args, fmt); - va_format(args, fmt); + this->error = unique_ptr<char>(strdup(String::va_fmt(args, fmt).c_str())); va_end(args); } |