Merge pull request #181 from AtomicRobotMan0101/main
Update README.md
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 94bbc86..644df24 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,7 +27,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
cmake_minimum_required(VERSION 3.1)
-project(Snappy VERSION 1.2.0 LANGUAGES C CXX)
+project(Snappy VERSION 1.2.1 LANGUAGES C CXX)
# C++ standard can be overridden when this is used as a sub-project.
if(NOT CMAKE_CXX_STANDARD)
diff --git a/snappy.cc b/snappy.cc
index 08c2a98..56b8c82 100644
--- a/snappy.cc
+++ b/snappy.cc
@@ -1792,6 +1792,10 @@
return decompressor.ReadUncompressedLength(result);
}
+size_t Compress(Source* reader, Sink* writer) {
+ return Compress(reader, writer, CompressionOptions{});
+}
+
size_t Compress(Source* reader, Sink* writer, CompressionOptions options) {
assert(options.level == 1 || options.level == 2);
int token = 0;
@@ -2299,6 +2303,12 @@
}
void RawCompress(const char* input, size_t input_length, char* compressed,
+ size_t* compressed_length) {
+ RawCompress(input, input_length, compressed, compressed_length,
+ CompressionOptions{});
+}
+
+void RawCompress(const char* input, size_t input_length, char* compressed,
size_t* compressed_length, CompressionOptions options) {
ByteArraySource reader(input, input_length);
UncheckedByteArraySink writer(compressed);
@@ -2309,6 +2319,12 @@
}
void RawCompressFromIOVec(const struct iovec* iov, size_t uncompressed_length,
+ char* compressed, size_t* compressed_length) {
+ RawCompressFromIOVec(iov, uncompressed_length, compressed, compressed_length,
+ CompressionOptions{});
+}
+
+void RawCompressFromIOVec(const struct iovec* iov, size_t uncompressed_length,
char* compressed, size_t* compressed_length,
CompressionOptions options) {
SnappyIOVecReader reader(iov, uncompressed_length);
@@ -2319,6 +2335,11 @@
*compressed_length = writer.CurrentDestination() - compressed;
}
+size_t Compress(const char* input, size_t input_length,
+ std::string* compressed) {
+ return Compress(input, input_length, compressed, CompressionOptions{});
+}
+
size_t Compress(const char* input, size_t input_length, std::string* compressed,
CompressionOptions options) {
// Pre-grow the buffer to the max length of the compressed output
@@ -2332,6 +2353,11 @@
}
size_t CompressFromIOVec(const struct iovec* iov, size_t iov_cnt,
+ std::string* compressed) {
+ return CompressFromIOVec(iov, iov_cnt, compressed, CompressionOptions{});
+}
+
+size_t CompressFromIOVec(const struct iovec* iov, size_t iov_cnt,
std::string* compressed, CompressionOptions options) {
// Compute the number of bytes to be compressed.
size_t uncompressed_length = 0;
diff --git a/snappy.h b/snappy.h
index bde378b..2f1b802 100644
--- a/snappy.h
+++ b/snappy.h
@@ -78,8 +78,10 @@
// Compress the bytes read from "*reader" and append to "*writer". Return the
// number of bytes written.
+ // First version is to preserve ABI.
+ size_t Compress(Source* reader, Sink* writer);
size_t Compress(Source* reader, Sink* writer,
- CompressionOptions options = {});
+ CompressionOptions options);
// Find the uncompressed length of the given stream, as given by the header.
// Note that the true length could deviate from this; the stream could e.g.
@@ -98,16 +100,22 @@
// Original contents of *compressed are lost.
//
// REQUIRES: "input[]" is not an alias of "*compressed".
+ // First version is to preserve ABI.
size_t Compress(const char* input, size_t input_length,
- std::string* compressed, CompressionOptions options = {});
+ std::string* compressed);
+ size_t Compress(const char* input, size_t input_length,
+ std::string* compressed, CompressionOptions options);
// Same as `Compress` above but taking an `iovec` array as input. Note that
// this function preprocesses the inputs to compute the sum of
// `iov[0..iov_cnt-1].iov_len` before reading. To avoid this, use
// `RawCompressFromIOVec` below.
+ // First version is to preserve ABI.
+ size_t CompressFromIOVec(const struct iovec* iov, size_t iov_cnt,
+ std::string* compressed);
size_t CompressFromIOVec(const struct iovec* iov, size_t iov_cnt,
std::string* compressed,
- CompressionOptions options = {});
+ CompressionOptions options);
// Decompresses "compressed[0..compressed_length-1]" to "*uncompressed".
// Original contents of "*uncompressed" are lost.
@@ -151,14 +159,18 @@
// ... Process(output, output_length) ...
// delete [] output;
void RawCompress(const char* input, size_t input_length, char* compressed,
- size_t* compressed_length, CompressionOptions options = {});
+ size_t* compressed_length);
+ void RawCompress(const char* input, size_t input_length, char* compressed,
+ size_t* compressed_length, CompressionOptions options);
// Same as `RawCompress` above but taking an `iovec` array as input. Note that
// `uncompressed_length` is the total number of bytes to be read from the
// elements of `iov` (_not_ the number of elements in `iov`).
void RawCompressFromIOVec(const struct iovec* iov, size_t uncompressed_length,
+ char* compressed, size_t* compressed_length);
+ void RawCompressFromIOVec(const struct iovec* iov, size_t uncompressed_length,
char* compressed, size_t* compressed_length,
- CompressionOptions options = {});
+ CompressionOptions options);
// Given data in "compressed[0..compressed_length-1]" generated by
// calling the Snappy::Compress routine, this routine