diff options
author | Kirill Stoimenov <kstoimenov@google.com> | 2022-04-26 23:24:06 +0300 |
---|---|---|
committer | Kirill Stoimenov <kstoimenov@google.com> | 2022-04-26 23:24:06 +0300 |
commit | aabeb5eb7f0aaa2c80147d904959c882cdeba1e5 (patch) | |
tree | c2cbd63fa7047f616693b1613147c35fbb38f1a3 /libcxxabi/src/demangle | |
parent | ce8f42d4af2cf56c96f5a8cc4c4a02bf6b790ccc (diff) |
Revert "[demangler] Simplify OutputBuffer initialization"
Reverting due to a bot failure:
https://lab.llvm.org/buildbot/#/builders/5/builds/22738
This reverts commit 5b3ca24a35e91bf9c19af856e7f92c69b17f989e.
Diffstat (limited to 'libcxxabi/src/demangle')
-rw-r--r-- | libcxxabi/src/demangle/Utility.h | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/libcxxabi/src/demangle/Utility.h b/libcxxabi/src/demangle/Utility.h index 00572880237a..6e0fa38632c8 100644 --- a/libcxxabi/src/demangle/Utility.h +++ b/libcxxabi/src/demangle/Utility.h @@ -69,9 +69,7 @@ class OutputBuffer { public: OutputBuffer(char *StartBuf, size_t Size) - : Buffer(StartBuf), BufferCapacity(Size) {} - OutputBuffer(char *StartBuf, size_t *SizePtr) - : OutputBuffer(StartBuf, StartBuf ? *SizePtr : 0) {} + : Buffer(StartBuf), CurrentPosition(0), BufferCapacity(Size) {} OutputBuffer() = default; // Non-copyable OutputBuffer(const OutputBuffer &) = delete; @@ -79,6 +77,12 @@ public: operator StringView() const { return StringView(Buffer, CurrentPosition); } + void reset(char *Buffer_, size_t BufferCapacity_) { + CurrentPosition = 0; + Buffer = Buffer_; + BufferCapacity = BufferCapacity_; + } + /// If a ParameterPackExpansion (or similar type) is encountered, the offset /// into the pack that we're currently printing. unsigned CurrentPackIndex = std::numeric_limits<unsigned>::max(); @@ -193,6 +197,21 @@ public: ScopedOverride &operator=(const ScopedOverride &) = delete; }; +inline bool initializeOutputBuffer(char *Buf, size_t *N, OutputBuffer &OB, + size_t InitSize) { + size_t BufferSize; + if (Buf == nullptr) { + Buf = static_cast<char *>(std::malloc(InitSize)); + if (Buf == nullptr) + return false; + BufferSize = InitSize; + } else + BufferSize = *N; + + OB.reset(Buf, BufferSize); + return true; +} + DEMANGLE_NAMESPACE_END #endif |