< prev index next >
src/hotspot/share/utilities/ostream.cpp
Print this page
rev 59277 : [mq]: v3
*** 27,36 ****
--- 27,37 ----
#include "compiler/compileLog.hpp"
#include "memory/allocation.inline.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/arguments.hpp"
#include "runtime/os.inline.hpp"
+ #include "runtime/orderAccess.hpp"
#include "runtime/vm_version.hpp"
#include "utilities/defaultStream.hpp"
#include "utilities/macros.hpp"
#include "utilities/ostream.hpp"
#include "utilities/vmError.hpp"
*** 366,379 ****
void stringStream::reset() {
buffer_pos = 0; _precount = 0; _position = 0;
zero_terminate();
}
! char* stringStream::as_string() const {
! char* copy = NEW_RESOURCE_ARRAY(char, buffer_pos + 1);
strncpy(copy, buffer, buffer_pos);
copy[buffer_pos] = 0; // terminating null
return copy;
}
stringStream::~stringStream() {
if (buffer_fixed == false && buffer != NULL) {
--- 367,386 ----
void stringStream::reset() {
buffer_pos = 0; _precount = 0; _position = 0;
zero_terminate();
}
! char* stringStream::as_string(bool c_heap) const {
! char* copy = c_heap ?
! NEW_C_HEAP_ARRAY(char, buffer_pos + 1, mtInternal) : NEW_RESOURCE_ARRAY(char, buffer_pos + 1);
strncpy(copy, buffer, buffer_pos);
copy[buffer_pos] = 0; // terminating null
+ if (c_heap) {
+ // Need to ensure our content is written to memory before we return
+ // the pointer to it.
+ OrderAccess::storestore();
+ }
return copy;
}
stringStream::~stringStream() {
if (buffer_fixed == false && buffer != NULL) {
< prev index next >