From 8303bb1b33a4db1d688d32f9be10976b0b54f209 Mon Sep 17 00:00:00 2001 From: "jorlow@chromium.org" Date: Tue, 22 Mar 2011 23:24:02 +0000 Subject: Pull from upstream. git-svn-id: https://leveldb.googlecode.com/svn/trunk@14 62dab493-f737-651d-591e-8d6aee1b9529 --- port/port_android.h | 21 ++++++--------------- port/port_chromium.cc | 14 +++++++------- port/port_chromium.h | 8 ++++---- port/port_example.h | 13 +++++++------ port/port_posix.h | 25 ++++++++----------------- 5 files changed, 32 insertions(+), 49 deletions(-) (limited to 'port') diff --git a/port/port_android.h b/port/port_android.h index 2770a0c..ca0362d 100644 --- a/port/port_android.h +++ b/port/port_android.h @@ -82,29 +82,20 @@ class AtomicPointer { } }; -/** - * TODO(gabor): Implement actual compress - * This is a hack - it just copies input to output. - * No actual compression occurs. - */ -inline void Lightweight_Compress( +// TODO(gabor): Implement actual compress +inline bool Snappy_Compress( const char* input, size_t input_length, std::string* output) { - output->copy((char*)input,0,input_length); + return false; } -/** - * TODO(gabor): Implement actual compress - * This is a hack - it just copies input to output. - * No actual uncompression occurs. - */ -inline bool Lightweight_Uncompress( +// TODO(gabor): Implement actual uncompress +inline bool Snappy_Uncompress( const char* input_data, size_t input_length, std::string* output) { - output->copy((char*)input_data,0,input_length); - return (bool)1; + return false; } inline void SHA1_Hash(const char* data, size_t len, char* hash_array) { diff --git a/port/port_chromium.cc b/port/port_chromium.cc index 4026aa3..2ab49b9 100644 --- a/port/port_chromium.cc +++ b/port/port_chromium.cc @@ -49,20 +49,21 @@ void CondVar::SignalAll() { cv_.Broadcast(); } -void Lightweight_Compress(const char* input, size_t input_length, - std::string* output) { +bool Snappy_Compress(const char* input, size_t input_length, + std::string* output) { #if defined(USE_SNAPPY) output->resize(snappy::MaxCompressedLength(input_length)); size_t outlen; snappy::RawCompress(input, input_length, &(*output)[0], &outlen); output->resize(outlen); + return true; #else - output->assign(input, input_length); + return false; #endif } -bool Lightweight_Uncompress(const char* input_data, size_t input_length, - std::string* output) { +bool Snappy_Uncompress(const char* input_data, size_t input_length, + std::string* output) { #if defined(USE_SNAPPY) size_t ulength; if (!snappy::GetUncompressedLength(input_data, input_length, &ulength)) { @@ -71,8 +72,7 @@ bool Lightweight_Uncompress(const char* input_data, size_t input_length, output->resize(ulength); return snappy::RawUncompress(input_data, input_length, &(*output)[0]); #else - output->assign(input_data, input_length); - return true; + return false; #endif } diff --git a/port/port_chromium.h b/port/port_chromium.h index b33bdde..e349f8f 100644 --- a/port/port_chromium.h +++ b/port/port_chromium.h @@ -89,10 +89,10 @@ inline void SHA1_Hash(const char* data, size_t len, char* hash_array) { reinterpret_cast(hash_array)); } -void Lightweight_Compress(const char* input, size_t input_length, - std::string* output); -bool Lightweight_Uncompress(const char* input_data, size_t input_length, - std::string* output); +bool Snappy_Compress(const char* input, size_t input_length, + std::string* output); +bool Snappy_Uncompress(const char* input_data, size_t input_length, + std::string* output); inline bool GetHeapProfile(void (*func)(void*, const char*, int), void* arg) { return false; diff --git a/port/port_example.h b/port/port_example.h index ee25a01..cf72617 100644 --- a/port/port_example.h +++ b/port/port_example.h @@ -96,15 +96,16 @@ extern void SHA1_Hash(const char* data, size_t len, char* hash_array); // ------------------ Compression ------------------- -// Store the lightweight compression of "input[0,input_length-1]" in *output. -extern void Lightweight_Compress(const char* input, size_t input_length, - std::string* output); +// Store the snappy compression of "input[0,input_length-1]" in *output. +// Returns false if snappy is not supported by this port. +extern bool Snappy_Compress(const char* input, size_t input_length, + std::string* output); -// Attempt to lightweight uncompress input[0,input_length-1] into *output. +// Attempt to snappy uncompress input[0,input_length-1] into *output. // Returns true if successful, false if the input is invalid lightweight // compressed data. -extern bool Lightweight_Uncompress(const char* input_data, size_t input_length, - std::string* output); +extern bool Snappy_Uncompress(const char* input_data, size_t input_length, + std::string* output); // ------------------ Miscellaneous ------------------- diff --git a/port/port_posix.h b/port/port_posix.h index e7bc5b8..7adbc01 100644 --- a/port/port_posix.h +++ b/port/port_posix.h @@ -77,25 +77,16 @@ inline void SHA1_Hash(const char* data, size_t len, char* hash_array) { SHA1_Hash_Portable(data, len, hash_array); } -/** - * TODO(gabor): Implement actual compress - * This is a hack - it just copies input to output. - * No actual compression occurs. - */ -inline void Lightweight_Compress(const char* input, size_t input_length, - std::string* output) { - output->assign(input, input_length); +// TODO(gabor): Implement actual compress +inline bool Snappy_Compress(const char* input, size_t input_length, + std::string* output) { + return false; } -/** - * TODO(gabor): Implement actual uncompress - * This is a hack - it just copies input to output. - * No actual uncompression occurs. - */ -inline bool Lightweight_Uncompress(const char* input_data, size_t input_length, - std::string* output) { - output->assign(input_data, input_length); - return true; +// TODO(gabor): Implement actual uncompress +inline bool Snappy_Uncompress(const char* input_data, size_t input_length, + std::string* output) { + return false; } inline bool GetHeapProfile(void (*func)(void*, const char*, int), void* arg) { -- cgit v1.2.1