summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPatrick Wildt <patrick@cvs.openbsd.org>2019-02-04 16:55:18 +0000
committerPatrick Wildt <patrick@cvs.openbsd.org>2019-02-04 16:55:18 +0000
commitb07c0bf38012aa2c73d4281b8b63c4b013d36673 (patch)
treee0ec0746fa6aef1021fc12e28f9d3f8a262456a0 /lib
parent7b0ee4c38d2bb595d68a74569b70a6b0f29a15eb (diff)
Import libc++abi 7.0.1.
Diffstat (limited to 'lib')
-rw-r--r--lib/libcxxabi/src/demangle/Utility.h31
1 files changed, 16 insertions, 15 deletions
diff --git a/lib/libcxxabi/src/demangle/Utility.h b/lib/libcxxabi/src/demangle/Utility.h
index b5e9b5e42cf..39092436283 100644
--- a/lib/libcxxabi/src/demangle/Utility.h
+++ b/lib/libcxxabi/src/demangle/Utility.h
@@ -71,6 +71,22 @@ public:
BufferCapacity = BufferCapacity_;
}
+ /// Create an OutputStream from a buffer and a size. If either of these are
+ /// null a buffer is allocated.
+ static OutputStream create(char *StartBuf, size_t *Size, size_t AllocSize) {
+ OutputStream Result;
+
+ if (!StartBuf || !Size) {
+ StartBuf = static_cast<char *>(std::malloc(AllocSize));
+ if (StartBuf == nullptr)
+ std::terminate();
+ Size = &AllocSize;
+ }
+
+ Result.reset(StartBuf, *Size);
+ return Result;
+ }
+
/// 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();
@@ -170,21 +186,6 @@ public:
SwapAndRestore &operator=(const SwapAndRestore &) = delete;
};
-inline bool initializeOutputStream(char *Buf, size_t *N, OutputStream &S,
- 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;
-
- S.reset(Buf, BufferSize);
- return true;
-}
-
} // namespace
#endif