Skip to content

Commit 4cc505d

Browse files
committed
create stream
1 parent 764b34c commit 4cc505d

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/runtime/vm/executable.cc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ std::string Executable::Stats() const {
168168

169169
TVMByteArray Executable::Save() {
170170
// Initialize the stream object.
171-
strm_ = new dmlc::MemoryStringStream(&code_);
171+
dmlc::MemoryStringStream strm(const_cast<std::string*>(&code_));
172+
strm_ = &strm;
172173

173174
uint64_t header = kTVMVMBytecodeMagic;
174175
strm_->Write(header);
@@ -407,10 +408,8 @@ runtime::Module Executable::Load(const std::string& code, const runtime::Module
407408
std::shared_ptr<Executable> exec = std::make_shared<Executable>();
408409
exec->code_ = code;
409410
exec->lib = lib;
410-
// Initialize the stream object.
411-
if (exec->strm_ == nullptr) {
412-
exec->strm_ = new dmlc::MemoryStringStream(&exec->code_);
413-
}
411+
dmlc::MemoryStringStream strm(const_cast<std::string*>(&code));
412+
exec->strm_ = &strm;
414413

415414
// Check header.
416415
uint64_t header;

0 commit comments

Comments
 (0)