Skip to content

Commit

Permalink
Free compressor.
Browse files Browse the repository at this point in the history
  • Loading branch information
hzeller committed Jun 24, 2023
1 parent 4ef7302 commit 76290e9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ sudo dnf install pandoc # If you want to recreate the man page

```bash
sudo apt install cmake git g++ pkg-config
sudo apt install libgraphicsmagick++-dev libturbojpeg-dev libexif-dev libswscale-dev libdeflate # needed libs
sudo apt install libgraphicsmagick++-dev libturbojpeg-dev libexif-dev libswscale-dev libdeflate-dev # needed libs

# If you want to include video decoding, also install these additional libraries
sudo apt install libavcodec-dev libavformat-dev
Expand Down
4 changes: 3 additions & 1 deletion src/timg-png.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ static size_t EncodePNGInternal(const Framebuffer &fb, int compression_level,
block.StartNextBlock("IDAT");

const int compress_avail = size - (block.writePos() - (uint8_t *)buffer);
libdeflate_compressor *compressor =
libdeflate_compressor *const compressor =
libdeflate_alloc_compressor(compression_level);
const int bytes_per_pixel = with_alpha ? 4 : 3;
const rgba_t *current_line = fb.begin();
Expand All @@ -137,7 +137,9 @@ static size_t EncodePNGInternal(const Framebuffer &fb, int compression_level,
compressor, compress_buffer, out - compress_buffer, //
block.writePos(), compress_avail);
block.updateWritten(written_size);

delete[] compress_buffer;
libdeflate_free_compressor(compressor);

block.StartNextBlock("IEND");
return block.Finalize() - (uint8_t *)buffer;
Expand Down

0 comments on commit 76290e9

Please sign in to comment.