1
0
This repository has been archived on 2024-09-10. You can view files and clone it, but cannot push or open issues or pull requests.
levedb-mcpe-legacy/db/snappy_compressor.cc

30 lines
696 B
C++

#ifdef SNAPPY
#include "leveldb/snappy_compressor.h"
#include <snappy/snappy.h>
namespace leveldb {
void SnappyCompressor::compressImpl(const char* input, size_t length, ::std::string& output) const
{
output.resize(snappy::MaxCompressedLength(length));
size_t outlen;
snappy::RawCompress(input, length, &output[0], &outlen);
output.resize(outlen);
}
bool SnappyCompressor::decompress(const char* input, size_t length, std::string& output) const
{
size_t ulength;
if (!snappy::GetUncompressedLength(input, length, &ulength))
return false; //could not decompress
output.resize(ulength);
return snappy::RawUncompress(input, length, (char*)output.data());
}
}
#endif