MCPcopy Create free account
hub / github.com/HumbleNet/HumbleNet / syncsearch

Function syncsearch

3rdparty/Amalgamate/juce_core_amalgam.cpp:22852–22870  ·  view source on GitHub ↗

Search buf[0..len-1] for the pattern: 0, 0, 0xff, 0xff. Return when found or when out of input. When called, *have is the number of pattern bytes found in order so far, in 0..3. On return *have is updated to the new state. If on return *have equals four, then the pattern was found and the return value is how many bytes were read including the last byte of the pattern. If *have

Source from the content-addressed store, hash-verified

22850 zero for the first call.
22851 */
22852local unsigned syncsearch (unsigned FAR *have, unsigned char FAR *buf, unsigned len)
22853{
22854 unsigned got;
22855 unsigned next;
22856
22857 got = *have;
22858 next = 0;
22859 while (next < len && got < 4) {
22860 if ((int)(buf[next]) == (got < 2 ? 0 : 0xff))
22861 got++;
22862 else if (buf[next])
22863 got = 0;
22864 else
22865 got = 4 - got;
22866 next++;
22867 }
22868 *have = got;
22869 return next;
22870}
22871
22872int ZEXPORT inflateSync (z_streamp strm)
22873{

Callers 2

inflateSyncFunction · 0.85
inflate.cFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected