diff -r 0927d8c7296f -r 22961d673487 src/hotspot/share/utilities/ostream.hpp --- a/src/hotspot/share/utilities/ostream.hpp Wed May 22 07:10:54 2019 +0200 +++ b/src/hotspot/share/utilities/ostream.hpp Wed May 22 09:33:22 2019 +0200 @@ -190,19 +190,25 @@ } }; -// for writing to strings; buffer will expand automatically +// for writing to strings; buffer will expand automatically. +// Buffer will always be zero-terminated. class stringStream : public outputStream { protected: char* buffer; size_t buffer_pos; size_t buffer_length; bool buffer_fixed; - DEBUG_ONLY(ResourceMark* rm;) public: + // Create a stringStream using an internal buffer of initially initial_bufsize size; + // will be enlarged on demand. There is no maximum cap. stringStream(size_t initial_bufsize = 256); + // Creates a stringStream using a caller-provided buffer. Will truncate silently if + // it overflows. stringStream(char* fixed_buffer, size_t fixed_buffer_size); ~stringStream(); virtual void write(const char* c, size_t len); + // Return number of characters written into buffer, excluding terminating zero and + // subject to truncation in static buffer mode. size_t size() { return buffer_pos; } const char* base() { return buffer; } void reset() { buffer_pos = 0; _precount = 0; _position = 0; }