From b754f607aa345e7ad406e07616d462ac56f41b89 Mon Sep 17 00:00:00 2001 From: Eugene Kliuchnikov Date: Wed, 21 Sep 2016 15:37:45 +0200 Subject: [PATCH] Update python module * use new decoder API --- python/brotlimodule.cc | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/python/brotlimodule.cc b/python/brotlimodule.cc index 4849bca..2fcfaf3 100644 --- a/python/brotlimodule.cc +++ b/python/brotlimodule.cc @@ -223,19 +223,18 @@ static PyObject* brotli_decompress(PyObject *self, PyObject *args, PyObject *key std::vector output; const size_t kBufferSize = 65536; uint8_t* buffer = new uint8_t[kBufferSize]; - BrotliState* state = BrotliCreateState(0, 0, 0); + BrotliDecoderState* state = BrotliDecoderCreateInstance(0, 0, 0); if (custom_dictionary_length != 0) { - BrotliSetCustomDictionary(custom_dictionary_length, custom_dictionary, state); + BrotliDecoderSetCustomDictionary(state, custom_dictionary_length, custom_dictionary); } - BrotliResult result = BROTLI_RESULT_NEEDS_MORE_OUTPUT; - while (result == BROTLI_RESULT_NEEDS_MORE_OUTPUT) { + BrotliDecoderResult result = BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT; + while (result == BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT) { size_t available_out = kBufferSize; uint8_t* next_out = buffer; - size_t total_out = 0; - result = BrotliDecompressStream(&length, &input, - &available_out, &next_out, - &total_out, state); + result = BrotliDecoderDecompressStream(&length, &input, + &available_out, &next_out, + 0, state); size_t used_out = kBufferSize - available_out; if (used_out != 0) output.insert(output.end(), buffer, buffer + used_out); @@ -247,7 +246,7 @@ static PyObject* brotli_decompress(PyObject *self, PyObject *args, PyObject *key PyErr_SetString(BrotliError, "BrotliDecompress failed"); } - BrotliDestroyState(state); + BrotliDecoderDestroyInstance(state); delete[] buffer; return ret;