Skip to content

Commit

Permalink
fix read buffer bug
Browse files Browse the repository at this point in the history
  • Loading branch information
emjotde committed Dec 13, 2018
1 parent 8115bcc commit 0faa7a4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/common/file_stream.h
Expand Up @@ -178,11 +178,9 @@ class InputFileStream {
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>
Expand All @@ -206,9 +204,10 @@ class InputFileStream {
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
Expand Down Expand Up @@ -301,6 +300,7 @@ class OutputFileStream {
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_;
};
Expand Down

0 comments on commit 0faa7a4

Please sign in to comment.