From 24ae6294a4a97d4dfe0e43f7bcd52811b6346c17 Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Thu, 16 Feb 2017 19:38:21 +0000 Subject: Finish breaking the dependency from Utility. Differential Revision: https://reviews.llvm.org/D29964 llvm-svn: 295368 --- lldb/source/Utility/Error.cpp | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) (limited to 'lldb/source/Utility/Error.cpp') diff --git a/lldb/source/Utility/Error.cpp b/lldb/source/Utility/Error.cpp index 3b3d1fa32c4..0b14949e88f 100644 --- a/lldb/source/Utility/Error.cpp +++ b/lldb/source/Utility/Error.cpp @@ -20,8 +20,8 @@ #include "llvm/ADT/SmallVector.h" // Project includes -#include "lldb/Host/PosixApi.h" #include "lldb/Utility/Error.h" +#include "lldb/Utility/VASPrintf.h" using namespace lldb; using namespace lldb_private; @@ -233,25 +233,9 @@ int Error::SetErrorStringWithVarArg(const char *format, va_list args) { if (Success()) SetErrorToGenericError(); - // Try and fit our error into a 1024 byte buffer first... - llvm::SmallVector buf; - buf.resize(1024); - // Copy in case our first call to vsnprintf doesn't fit into our - // allocated buffer above - va_list copy_args; - va_copy(copy_args, args); - unsigned length = ::vsnprintf(buf.data(), buf.size(), format, args); - if (length >= buf.size()) { - // The error formatted string didn't fit into our buffer, resize it - // to the exact needed size, and retry - buf.resize(length + 1); - length = ::vsnprintf(buf.data(), buf.size(), format, copy_args); - va_end(copy_args); - assert(length < buf.size()); - } - m_string.assign(buf.data(), length); - va_end(args); - return length; + llvm::SmallString<1024> buf; + VASprintf(buf, format, args); + return buf.size(); } else { m_string.clear(); } -- cgit v1.2.3