lib/ruby/truffle/pr-zlib/lib/pr/rbzlib.rb
# Compute the CRC-32 of a data stream.
#
Compute the CRC-32 of a data stream.
Compute the CRC - 32 of a data stream .
def crc32(crc, buf, len=0)
    return 0 if buf.nil?
    len = buf.length if len == 0
    crc = crc ^ 0xffffffff
    i = 0
    while len >= 8
      while i < 8
        crc = @@crc_table[(crc ^ buf[i].ord) & 0xff] ^ (crc >> 8)
        i += 1
      end
      len -= 8
    end
    if len != 0
      loop do
        crc = @@crc_table[(crc ^ buf[i].ord) & 0xff] ^ (crc >> 8)
        i += 1
        len -= 1
        break if len == 0
      end
    end
    crc ^ 0xffffffff
  end
def crc32 ( crc , buf , len = 0 ) return 0 if buf . nil? len = buf . length if len == 0 crc = crc ^ 0xffffffff i = 0 while len >= 8 while i < 8 crc = @@crc_table [ ( crc ^ buf [ i ] . ord ) & 0xff ] ^ ( crc >> 8 ) i += 1 end len -= 8 end if len != 0 loop do crc = @@crc_table [ ( crc ^ buf [ i ] . ord ) & 0xff ] ^ ( crc >> 8 ) i += 1 len -= 1 break if len == 0 end end crc ^ 0xffffffff end
Compute the CRC-32 of a data stream.
Compute the CRC - 32 of a data stream .
crc
<not_specific>
buf
<not_specific>
len
<not_specific>