| Index: third_party/protobuf/src/google/protobuf/io/gzip_stream.cc
|
| diff --git a/third_party/protobuf/src/google/protobuf/io/gzip_stream.cc b/third_party/protobuf/src/google/protobuf/io/gzip_stream.cc
|
| index fe1f3319d31baaf2e4302a7ec26008d2b28fa9e1..1be6c8635952429b820b2a9570261031fd0fb77c 100644
|
| --- a/third_party/protobuf/src/google/protobuf/io/gzip_stream.cc
|
| +++ b/third_party/protobuf/src/google/protobuf/io/gzip_stream.cc
|
| @@ -1,6 +1,6 @@
|
| // Protocol Buffers - Google's data interchange format
|
| // Copyright 2008 Google Inc. All rights reserved.
|
| -// http://code.google.com/p/protobuf/
|
| +// https://developers.google.com/protocol-buffers/
|
| //
|
| // Redistribution and use in source and binary forms, with or without
|
| // modification, are permitted provided that the following conditions are
|
| @@ -33,12 +33,12 @@
|
| // This file contains the implementation of classes GzipInputStream and
|
| // GzipOutputStream.
|
|
|
| -#include "config.h"
|
|
|
| #if HAVE_ZLIB
|
| #include <google/protobuf/io/gzip_stream.h>
|
|
|
| #include <google/protobuf/stubs/common.h>
|
| +#include <google/protobuf/stubs/logging.h>
|
|
|
| namespace google {
|
| namespace protobuf {
|
| @@ -48,7 +48,8 @@ static const int kDefaultBufferSize = 65536;
|
|
|
| GzipInputStream::GzipInputStream(
|
| ZeroCopyInputStream* sub_stream, Format format, int buffer_size)
|
| - : format_(format), sub_stream_(sub_stream), zerror_(Z_OK) {
|
| + : format_(format), sub_stream_(sub_stream), zerror_(Z_OK), byte_count_(0) {
|
| + zcontext_.state = Z_NULL;
|
| zcontext_.zalloc = Z_NULL;
|
| zcontext_.zfree = Z_NULL;
|
| zcontext_.opaque = Z_NULL;
|
| @@ -134,6 +135,7 @@ bool GzipInputStream::Next(const void** data, int* size) {
|
| if (zcontext_.next_out != NULL) {
|
| // sub_stream_ may have concatenated streams to follow
|
| zerror_ = inflateEnd(&zcontext_);
|
| + byte_count_ += zcontext_.total_out;
|
| if (zerror_ != Z_OK) {
|
| return false;
|
| }
|
| @@ -178,8 +180,12 @@ bool GzipInputStream::Skip(int count) {
|
| return ok;
|
| }
|
| int64 GzipInputStream::ByteCount() const {
|
| - return zcontext_.total_out +
|
| - (((uintptr_t)zcontext_.next_out) - ((uintptr_t)output_position_));
|
| + int64 ret = byte_count_ + zcontext_.total_out;
|
| + if (zcontext_.next_out != NULL && output_position_ != NULL) {
|
| + ret += reinterpret_cast<uintptr_t>(zcontext_.next_out) -
|
| + reinterpret_cast<uintptr_t>(output_position_);
|
| + }
|
| + return ret;
|
| }
|
|
|
| // =========================================================================
|
|
|