~ubuntu-branches/debian/stretch/protobuf/stretch

« back to all changes in this revision

Viewing changes to src/google/protobuf/io/zero_copy_stream_impl.cc

  • Committer: Package Import Robot
  • Author(s): Robert S. Edmonds
  • Date: 2014-09-11 22:50:10 UTC
  • mfrom: (10.1.9 experimental)
  • Revision ID: package-import@ubuntu.com-20140911225010-wt4yo9dpc1fzuq5g
Tags: 2.6.0-3
Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
413
413
 
414
414
LimitingInputStream::LimitingInputStream(ZeroCopyInputStream* input,
415
415
                                         int64 limit)
416
 
  : input_(input), limit_(limit) {}
 
416
  : input_(input), limit_(limit) {
 
417
  prior_bytes_read_ = input_->ByteCount();
 
418
}
417
419
 
418
420
LimitingInputStream::~LimitingInputStream() {
419
421
  // If we overshot the limit, back up.
457
459
 
458
460
int64 LimitingInputStream::ByteCount() const {
459
461
  if (limit_ < 0) {
460
 
    return input_->ByteCount() + limit_;
 
462
    return input_->ByteCount() + limit_ - prior_bytes_read_;
461
463
  } else {
462
 
    return input_->ByteCount();
 
464
    return input_->ByteCount() - prior_bytes_read_;
463
465
  }
464
466
}
465
467