Wrapper class for BrotliDecoderState that automatically calls BrotliDecoderDestroyInstance in its destructor.
| 179 | // Wrapper class for BrotliDecoderState that automatically calls |
| 180 | // BrotliDecoderDestroyInstance in its destructor. |
| 181 | class BrotliDecoderWrapper { |
| 182 | BrotliDecoderState* decoder_; |
| 183 | |
| 184 | public: |
| 185 | BrotliDecoderWrapper() : decoder_(BrotliDecoderCreateInstance(nullptr, nullptr, nullptr)) { |
| 186 | if (!decoder_) { |
| 187 | throw Error(ErrorCode::kerMallocFailed); |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | ~BrotliDecoderWrapper() { |
| 192 | BrotliDecoderDestroyInstance(decoder_); |
| 193 | } |
| 194 | |
| 195 | BrotliDecoderWrapper(const BrotliDecoderWrapper&) = delete; |
| 196 | BrotliDecoderWrapper& operator=(const BrotliDecoderWrapper&) = delete; |
| 197 | |
| 198 | [[nodiscard]] BrotliDecoderState* get() const { |
| 199 | return decoder_; |
| 200 | } |
| 201 | }; |
| 202 | |
| 203 | void BmffImage::brotliUncompress(const byte* compressedBuf, size_t compressedBufSize, DataBuf& arr) { |
| 204 | BrotliDecoderWrapper decoder; |
nothing calls this directly
no outgoing calls
no test coverage detected