Introduce a string_ostream string builder facilty
[oota-llvm.git] / lib / IRReader / IRReader.cpp
index 01aa074abad62f33af2a022cf6a938cf58709eb4..6d389d4dc4571ad22995a8195a113ee67919cdcc 100644 (file)
@@ -108,13 +108,9 @@ LLVMBool LLVMParseIRInContext(LLVMContextRef ContextRef,
 
   if(!*OutM) {
     if (OutMessage) {
-      std::string buf;
-      raw_string_ostream os(buf);
-
+      string_ostream os;
       Diag.print(nullptr, os, false);
-      os.flush();
-
-      *OutMessage = strdup(buf.c_str());
+      *OutMessage = strndup(os.str().data(), os.str().size());
     }
     return 1;
   }