This next cleanup of the demangler's OutputBuffer class addresses the initial allocation of the output buffer. Now that the buffer extension logic has hysteresis in it, there's no need for every use of OutputBuffer to explicitly create the initial buffer (using either 128 or 1024 as initial guesses).
For the default case we can rely on the buffer extension logic to create a good initial buffer. For the cases where the user is reusing a buffer, pass that information into the constructor. Thus the OutputBuffer's ownership of the buffer starts at its own lifetime start -- a nice bit of RAII. We can reduce the lifetime of this object in several cases.
That new constructor takes a 'size_t *' for the size argument, as all uses with a non-null buffer are passing through a malloc'd buffer from their own caller in this manner.
The buffer reset member function is never used, and is deleted.
The original buffer initialization code would return a failure code if that first malloc failed. Existing code either ignored that, called std::terminate with a FIXME, or returned an error code.
But that's not foolproof anyway, as a subsequent buffer extension failure ends up calling std::terminate. I am working on addressing that unfortunate failure mode in a manner more consistent with the C++ ABI design.
I have a patch dealing with the destructing part of this API coming up.
Looks good to me as an alternative to D124524