Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/marian-nmt/marian.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Junczys-Dowmunt <junczys@amu.edu.pl>2018-12-13 04:22:30 +0300
committerMarcin Junczys-Dowmunt <junczys@amu.edu.pl>2018-12-13 04:22:30 +0300
commit0faa7a4b913e9cf42ae0e04c61e6184461998cce (patch)
tree48474c6bc41062d89e32f79f935cfb50bcb622cc
parent8115bcc172f48f6497c4ea202d5ecf4a8f8adac3 (diff)
fix read buffer bug
-rwxr-xr-xsrc/common/file_stream.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/common/file_stream.h b/src/common/file_stream.h
index 9abe7e23..7f5236f7 100755
--- a/src/common/file_stream.h
+++ b/src/common/file_stream.h
@@ -178,11 +178,9 @@ public:
bool empty() { return istream_->peek() == std::ifstream::traits_type::eof(); }
void setbufsize(size_t size) const {
-#ifdef 0 // this is buggy, do nothing
istream_->rdbuf()->pubsetbuf(0, 0);
- readBuf_.reset(new char[size]);
- istream_->rdbuf()->pubsetbuf(readBuf_.get(), 0);
-#endif
+ readBuf_.resize(size);
+ istream_->rdbuf()->pubsetbuf(readBuf_.data(), readBuf_.size());
}
template <typename T>
@@ -206,9 +204,10 @@ private:
std::unique_ptr<std::istream> istream_;
boost::iostreams::file_descriptor_source fds_;
+ mutable std::vector<char> readBuf_; // for setbuf()
std::unique_ptr<boost::iostreams::stream_buffer<boost::iostreams::file_descriptor_source>> fdsBuffer_;
- mutable UPtr<char[]> readBuf_; // for setbuf()
+
};
// wrapper around std::getline() that handles Windows input files with extra CR
@@ -301,6 +300,7 @@ private:
marian::filesystem::Path file_;
std::unique_ptr<std::ostream> ostream_;
+
boost::iostreams::file_descriptor_sink fds_;
std::unique_ptr<boost::iostreams::stream_buffer<boost::iostreams::file_descriptor_sink>> fdsBuffer_;
};