A much faster solution would be the same approach rsync takes with its "rolling checksum." To calculate the weak checksum of each block as you roll along the length of the file, you only have to do a calculation involving the bytes rolling out and in. http://samba.anu.edu.au/rsync/tech_report/node3.html
Then, for only the blocks that match this weak checksum, do memcmp or a strong digest check.
Absolutely. The right way to do it is to use the memmem library call.
A much faster solution would be the same approach rsync takes with its "rolling checksum."
That's one way to improve performance, yes. (But it far predates rsync -- I think it might even predate Tridge.)
In many cases, a "look and skip" algorithm like KMP or BM will outperform a rolling checksum search; but of course if you've got 328MB of data on disk, nothing will make the search faster than the time it takes to read the data into RAM.
A much faster solution would be the same approach rsync takes with its "rolling checksum." To calculate the weak checksum of each block as you roll along the length of the file, you only have to do a calculation involving the bytes rolling out and in. http://samba.anu.edu.au/rsync/tech_report/node3.html
Then, for only the blocks that match this weak checksum, do memcmp or a strong digest check.