BUG: Math on size_t is unsigned, so the first loop was not using the correct bounds.  This fix uses memcmp() and a reasonably large buffer of zeros for efficiency.