File tree 1 file changed +2
-4
lines changed
1 file changed +2
-4
lines changed Original file line number Diff line number Diff line change @@ -4,16 +4,14 @@ use libdeflater::*;
4
4
5
5
pub fn deflate ( data : & [ u8 ] , level : u8 , max_size : & AtomicMin ) -> PngResult < Vec < u8 > > {
6
6
let mut compressor = Compressor :: new ( CompressionLvl :: new ( level. into ( ) ) . unwrap ( ) ) ;
7
- // If adhering to a max_size we need to include at least 9 extra bytes of slack space (as specified in docs).
8
7
let capacity = max_size
9
8
. get ( )
10
- . unwrap_or_else ( || compressor. zlib_compress_bound ( data. len ( ) ) )
11
- + 9 ;
9
+ . unwrap_or_else ( || compressor. zlib_compress_bound ( data. len ( ) ) ) ;
12
10
let mut dest = vec ! [ 0 ; capacity] ;
13
11
let len = compressor
14
12
. zlib_compress ( data, & mut dest)
15
13
. map_err ( |err| match err {
16
- CompressionError :: InsufficientSpace => PngError :: DeflatedDataTooLong ( capacity - 9 ) ,
14
+ CompressionError :: InsufficientSpace => PngError :: DeflatedDataTooLong ( capacity) ,
17
15
} ) ?;
18
16
dest. truncate ( len) ;
19
17
Ok ( dest)
You can’t perform that action at this time.
0 commit comments