]> iEval git - io-compress-brotli.git/commitdiff
Update use of deprecated brotli decoder APIs
authorQuim Rovira <quim@rovira.cat>
Sat, 13 Aug 2016 11:29:06 +0000 (13:29 +0200)
committerQuim Rovira <quim@rovira.cat>
Sat, 13 Aug 2016 12:04:28 +0000 (14:04 +0200)
This does not cover the use of BrotliDecompressedSize, and by looking at
the brotli code, it might even be a good idea to just use the streaming
interface right away.

Brotli.xs
lib/IO/Uncompress/Brotli.pm

index 8cb26c90c2a36e1b7e13efe5eb8d15fd7739cfea..b7f33d6012844a79533460534f8c06c40c7506af 100644 (file)
--- a/Brotli.xs
+++ b/Brotli.xs
@@ -27,32 +27,32 @@ SV* unbro(buffer)
     }
     Newx(decoded_buffer, decoded_size+1, uint8_t);
     decoded_buffer[decoded_size]=0;
-    if(!BrotliDecompressBuffer(encoded_size, encoded_buffer, &decoded_size, decoded_buffer)){
-        croak("Error in BrotliDecompressBuffer");
+    if(!BrotliDecoderDecompress(encoded_size, encoded_buffer, &decoded_size, decoded_buffer)){
+        croak("Error in BrotliDecoderDecompress");
     }
     RETVAL = newSV(0);
     sv_usepvn_flags(RETVAL, decoded_buffer, decoded_size, SV_HAS_TRAILING_NUL);
   OUTPUT:
     RETVAL
 
-SV* BrotliCreateState()
+SV* BrotliDecoderCreateInstance()
   CODE:
-    RETVAL = newSViv((IV)BrotliCreateState(NULL, NULL, NULL));
+    RETVAL = newSViv((IV)BrotliDecoderCreateInstance(NULL, NULL, NULL));
   OUTPUT:
     RETVAL
 
-void BrotliDestroyState(state)
+void BrotliDecoderDestroyInstance(state)
     SV* state
   CODE:
-    BrotliDestroyState((BrotliState*)SvIV(state));
+    BrotliDecoderDestroyInstance((BrotliDecoderState*)SvIV(state));
 
-SV* BrotliDecompressStream(state, in)
+SV* BrotliDecoderDecompressStream(state, in)
     SV* state
     SV* in
   PREINIT:
     uint8_t *next_in, *next_out;
     size_t available_in, available_out, total_out;
-    BrotliResult result;
+    BrotliDecoderResult result;
   CODE:
     next_in = (uint8_t*) SvPV(in, available_in);
     RETVAL = newSVpv("", 0);
@@ -60,9 +60,9 @@ SV* BrotliDecompressStream(state, in)
     while(result == BROTLI_RESULT_NEEDS_MORE_OUTPUT) {
         next_out = buffer;
         available_out=BUFFER_SIZE;
-        result = BrotliDecompressStream(&available_in, (const uint8_t**) &next_in, &available_out, &next_out, &total_out, (BrotliState*) SvIV(state));
+        result = BrotliDecoderDecompressStream((BrotliDecoderState*) SvIV(state), &available_in, (const uint8_t**) &next_in, &available_out, &next_out, &total_out);
         if(!result){
-             croak("Error in BrotliDecompressStream");
+             croak("Error in BrotliDecoderDecompressStream");
         }
         sv_catpvn(RETVAL, (const char*)buffer, BUFFER_SIZE-available_out);
     }
@@ -77,4 +77,4 @@ void BrotliSetCustomDictionary(state, dict)
     uint8_t *data;
   CODE:
     data = SvPV(dict, size);
-    BrotliSetCustomDictionary(size, data, (BrotliState*) SvIV(state));
+    BrotliDecoderSetCustomDictionary((BrotliDecoderState*) SvIV(state), size, data);
index 77e8b69293bc11b6a5f269fa5fa49e9206a02d54..2f37d8fb758f37f1d2202b60f2f610d30df9e6d5 100644 (file)
@@ -15,18 +15,18 @@ XSLoader::load('IO::Compress::Brotli', $VERSION);
 
 sub create {
        my ($class) = @_;
-       my $state = BrotliCreateState();
+       my $state = BrotliDecoderCreateInstance();
        bless \$state, $class
 }
 
 sub DESTROY {
        my ($self) = @_;
-       BrotliDestroyState($$self)
+       BrotliDecoderDestroyInstance($$self)
 }
 
 sub decompress {
        my ($self, $data) = @_;
-       BrotliDecompressStream($$self, $data)
+       BrotliDecoderDecompressStream($$self, $data)
 }
 
 # Untested, probably not working
This page took 0.036313 seconds and 4 git commands to generate.