lib/ruby/truffle/pr-zlib/lib/pr/rbzlib.rb
# For the default windowBits of 15 and memLevel of 8, this function returns
# a close to exact, as well as small, upper bound on the compressed size.
# They are coded as constants here for a reason--if the #define's are
# changed, then this function needs to be changed as well.  The return
# value for 15 and 8 only works for those exact settings.
#
# For any setting other than those defaults for windowBits and memLevel,
# the value returned is a conservative worst case for the maximum expansion
# resulting from using fixed blocks instead of stored blocks, which deflate
# can emit on compressed data for some combinations of the parameters.
#
# This function could be more sophisticated to provide closer upper bounds
# for every combination of windowBits and memLevel, as well as wrap.
# But even the conservative upper bound of about 14% expansion does not
# seem onerous for output buffer allocation.
For the default windowBits of 15 and memLevel of 8, this function returns
a close to exact, as well as small, upper bound on the compressed size.
They are coded as constants here for a reason--if the #define's are
changed, then this function needs to be changed as well.  The return
value for 15 and 8 only works for those exact settings.

For any setting other than those defaults for windowBits and memLevel,
the value returned is a conservative worst case for the maximum expansion
resulting from using fixed blocks instead of stored blocks, which deflate
can emit on compressed data for some combinations of the parameters.

This function could be more sophisticated to provide closer upper bounds
for every combination of windowBits and memLevel, as well as wrap.
But even the conservative upper bound of about 14% expansion does not
seem onerous for output buffer allocation.
For the default windowBits of 15 and memLevel of 8 this function returns a close to exact as well as small upper bound on the compressed size . They are coded as constants here for a reason -- if the #define ' s are changed then this function needs to be changed as well . The return value for 15 and 8 only works for those exact settings . For any setting other than those defaults for windowBits and memLevel the value returned is a conservative worst case for the maximum expansion resulting from using fixed blocks instead of stored blocks which deflate can emit on compressed data for some combinations of the parameters . This function could be more sophisticated to provide closer upper bounds for every combination of windowBits and memLevel as well as wrap . But even the conservative upper bound of about 14% expansion does not seem onerous for output buffer allocation .
def deflateBound(strm, sourceLen)
    destLen = sourceLen +
              ((sourceLen + 7) >> 3) + ((sourceLen + 63) >> 6) + 11
    if (strm.nil? || strm.state.nil?)
      return destLen
    end
    s = strm.state
    if (s.w_bits != 15 || s.hash_bits != 8 + 7)
      return destLen
    end
    return compressBound(sourceLen)
  end
def deflateBound ( strm , sourceLen ) destLen = sourceLen + ( ( sourceLen + 7 ) >> 3 ) + ( ( sourceLen + 63 ) >> 6 ) + 11 if ( strm . nil? || strm . state . nil? ) return destLen end s = strm . state if ( s . w_bits != 15 || s . hash_bits != 8 + 7 ) return destLen end return compressBound ( sourceLen ) end
For the default windowBits of 15 and memLevel of 8, this function returns
a close to exact, as well as small, upper bound on the compressed size.
For the default windowBits of 15 and memLevel of 8 this function returns a close to exact as well as small upper bound on the compressed size .
strm
<not_specific>
sourceLen
<not_specific>