Add files via upload

This commit is contained in:
SashaXser 2023-12-01 11:03:09 +03:00 committed by GitHub
parent 82210187a6
commit 2f0f432ceb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 8 deletions

View File

@ -238,15 +238,13 @@ static char* dumb_memmem(const char* haystack, unsigned int hlen,
if (nlen > hlen) return NULL;
if (nlen == 0) return (char*)haystack;
for (unsigned int i = 0; i <= hlen - nlen; i++) {
for (unsigned int j = 0; j < nlen; j++) {
if (haystack[i + j] != needle[j]) {
break;
}
unsigned int skip[256];
for (size_t i = 0; i < 256; ++i) skip[i] = nlen;
for (size_t i = 0; i < nlen - 1; ++i) skip[(unsigned char)needle[i]] = nlen - i - 1;
if (j == nlen - 1) {
return (char*)(haystack + i);
}
for (size_t i = nlen - 1; i < hlen; i += skip[(unsigned char)haystack[i]]) {
if (memcmp(haystack + i - nlen + 1, needle, nlen) == 0) {
return (char*)(haystack + i - nlen + 1);
}
}