diff options
Diffstat (limited to 'port/port_posix.h')
-rw-r--r-- | port/port_posix.h | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/port/port_posix.h b/port/port_posix.h index 2995026..ef01de3 100644 --- a/port/port_posix.h +++ b/port/port_posix.h @@ -80,12 +80,12 @@ class CondVar { Mutex* mu_; }; -inline bool Snappy_Compress(const char* input, size_t input_length, +inline bool Snappy_Compress(const char* input, size_t length, ::std::string* output) { #ifdef SNAPPY - output->resize(snappy::MaxCompressedLength(input_length)); + output->resize(snappy::MaxCompressedLength(length)); size_t outlen; - snappy::RawCompress(input, input_length, &(*output)[0], &outlen); + snappy::RawCompress(input, length, &(*output)[0], &outlen); output->resize(outlen); return true; #endif @@ -93,18 +93,22 @@ inline bool Snappy_Compress(const char* input, size_t input_length, return false; } -inline bool Snappy_Uncompress(const char* input_data, size_t input_length, - ::std::string* output) { +inline bool Snappy_GetUncompressedLength(const char* input, size_t length, + size_t* result) { #ifdef SNAPPY - size_t ulength; - if (!snappy::GetUncompressedLength(input_data, input_length, &ulength)) { - return false; - } - output->resize(ulength); - return snappy::RawUncompress(input_data, input_length, &(*output)[0]); + return snappy::GetUncompressedLength(input, length, result); +#else + return false; #endif +} +inline bool Snappy_Uncompress(const char* input, size_t length, + char* output) { +#ifdef SNAPPY + return snappy::RawUncompress(input, length, output); +#else return false; +#endif } inline bool GetHeapProfile(void (*func)(void*, const char*, int), void* arg) { |