From e750dc0f054ba74b0ce76dd2013e6728cc7a41c5 Mon Sep 17 00:00:00 2001 From: "snappy.mirrorbot@gmail.com" Date: Sun, 8 Jan 2012 17:55:48 +0000 Subject: [PATCH] Minor refactoring to accomodate changes in Google's internal code tree. git-svn-id: https://snappy.googlecode.com/svn/trunk@57 03e5f5b5-db94-4691-08a0-1a8bf15f6143 --- snappy-sinksource.cc | 1 - snappy-sinksource.h | 1 + snappy.cc | 13 +++++++++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/snappy-sinksource.cc b/snappy-sinksource.cc index 1017895..5844552 100644 --- a/snappy-sinksource.cc +++ b/snappy-sinksource.cc @@ -68,5 +68,4 @@ char* UncheckedByteArraySink::GetAppendBuffer(size_t len, char* scratch) { return dest_; } - } diff --git a/snappy-sinksource.h b/snappy-sinksource.h index 430baea..faabfa1 100644 --- a/snappy-sinksource.h +++ b/snappy-sinksource.h @@ -60,6 +60,7 @@ class Sink { // The default implementation always returns the scratch buffer. virtual char* GetAppendBuffer(size_t length, char* scratch); + private: // No copying Sink(const Sink&); diff --git a/snappy.cc b/snappy.cc index 5dce19a..3ce190c 100644 --- a/snappy.cc +++ b/snappy.cc @@ -805,6 +805,15 @@ static bool InternalUncompress(Source* r, SnappyDecompressor decompressor(r); uint32 uncompressed_len = 0; if (!decompressor.ReadUncompressedLength(&uncompressed_len)) return false; + return InternalUncompressAllTags( + &decompressor, writer, uncompressed_len, max_len); +} + +template +static bool InternalUncompressAllTags(SnappyDecompressor* decompressor, + Writer* writer, + uint32 uncompressed_len, + uint32 max_len) { // Protect against possible DoS attack if (static_cast(uncompressed_len) > max_len) { return false; @@ -813,8 +822,8 @@ static bool InternalUncompress(Source* r, writer->SetExpectedLength(uncompressed_len); // Process the entire input - decompressor.DecompressAllTags(writer); - return (decompressor.eof() && writer->CheckLength()); + decompressor->DecompressAllTags(writer); + return (decompressor->eof() && writer->CheckLength()); } bool GetUncompressedLength(Source* source, uint32* result) {