Merge pull request #250 from WillemKauf:compression-context-static

PiperOrigin-RevId: 959481048
diff --git a/snappy-internal.h b/snappy-internal.h
index 582e886..403f523 100644
--- a/snappy-internal.h
+++ b/snappy-internal.h
@@ -157,7 +157,7 @@
  private:
   char* mem_;        // the allocated memory, never nullptr
   size_t size_;      // the size of the allocated memory, never 0
-  bool owns_mem_;    // whether the destructor should free mem_
+  bool owns_mem_;
   uint16_t* table_;  // the pointer to the hashtable
   char* input_;      // the pointer to the input scratch buffer
   char* output_;     // the pointer to the output scratch buffer
diff --git a/snappy.cc b/snappy.cc
index 69cc209..5bcd580 100644
--- a/snappy.cc
+++ b/snappy.cc
@@ -76,7 +76,6 @@
 #include <cstring>
 #include <limits>
 #include <memory>
-#include <new>
 #include <string>
 #include <utility>
 #include <vector>
@@ -2466,17 +2465,6 @@
   *compressed_length = (writer.CurrentDestination() - compressed);
 }
 
-void RawCompress(const char* input, size_t input_length, char* compressed,
-                 size_t* compressed_length, CompressionOptions options,
-                 CompressionContext* ctx) {
-  ByteArraySource reader(input, input_length);
-  UncheckedByteArraySink writer(compressed);
-  Compress(&reader, &writer, options, ctx);
-
-  // Compute how many bytes were added
-  *compressed_length = (writer.CurrentDestination() - compressed);
-}
-
 void RawCompressFromIOVec(const struct iovec* iov, size_t uncompressed_length,
                           char* compressed, size_t* compressed_length) {
   RawCompressFromIOVec(iov, uncompressed_length, compressed, compressed_length,
@@ -2494,6 +2482,17 @@
   *compressed_length = writer.CurrentDestination() - compressed;
 }
 
+void RawCompress(const char* input, size_t input_length, char* compressed,
+                 size_t* compressed_length, CompressionOptions options,
+                 CompressionContext* ctx) {
+  ByteArraySource reader(input, input_length);
+  UncheckedByteArraySink writer(compressed);
+  Compress(&reader, &writer, options, ctx);
+
+  // Compute how many bytes were added
+  *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{});
diff --git a/snappy.h b/snappy.h
index 5413153..3653739 100644
--- a/snappy.h
+++ b/snappy.h
@@ -50,9 +50,9 @@
   class Source;
   class Sink;
 
-  namespace internal {
-  class WorkingMemory;
-  }  // end namespace internal
+namespace internal {
+class WorkingMemory;
+}  // end namespace internal
 
   struct CompressionOptions {
     // Compression level.
@@ -220,7 +220,6 @@
                    size_t* compressed_length);
   void RawCompress(const char* input, size_t input_length, char* compressed,
                    size_t* compressed_length, CompressionOptions options);
-
   // Same as the above, but uses the working memory of "*ctx" instead of
   // allocating it internally. See CompressionContext.
   void RawCompress(const char* input, size_t input_length, char* compressed,
diff --git a/snappy_unittest.cc b/snappy_unittest.cc
index 4f44cbf..8d83858 100644
--- a/snappy_unittest.cc
+++ b/snappy_unittest.cc
@@ -544,7 +544,7 @@
 }
 
 TEST(Snappy, CompressionContext) {
-  std::minstd_rand0 rng(snappy::GetFlag(FLAGS_test_random_seed));
+  std::minstd_rand0 rng(absl::GetFlag(FLAGS_test_random_seed));
   std::uniform_int_distribution<int> uniform_byte(0, 255);
 
   // A single context, reused across every compression below.