MCPcopy Create free account
hub / github.com/ValveSoftware/openvr / update_adler32

Function update_adler32

samples/shared/lodepng.cpp:2060–2081  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2058/* ////////////////////////////////////////////////////////////////////////// */
2059
2060static unsigned update_adler32(unsigned adler, const unsigned char* data, unsigned len)
2061{
2062 unsigned s1 = adler & 0xffff;
2063 unsigned s2 = (adler >> 16) & 0xffff;
2064
2065 while(len > 0)
2066 {
2067 /*at least 5550 sums can be done before the sums overflow, saving a lot of module divisions*/
2068 unsigned amount = len > 5550 ? 5550 : len;
2069 len -= amount;
2070 while(amount > 0)
2071 {
2072 s1 += (*data++);
2073 s2 += s1;
2074 amount--;
2075 }
2076 s1 %= 65521;
2077 s2 %= 65521;
2078 }
2079
2080 return (s2 << 16) | s1;
2081}
2082
2083/*Return the adler32 of the bytes data[0..len-1]*/
2084static unsigned adler32(const unsigned char* data, unsigned len)

Callers 1

adler32Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected