[+] AuMemmem (bc it was copy/pasted twice around the two different codebases and MSVC doesnt have a native memmem routine)
This commit is contained in:
parent
af438c8c17
commit
6daa8ef078
@ -45,3 +45,43 @@ static auline void *AuMemmove(void *dest, const void *src, size_t n)
|
||||
{
|
||||
return AURORA_RUNTIME_MEMMOVE(dest, src, n);
|
||||
}
|
||||
|
||||
static auline void *AuMemmem(const void *haystack, size_t haystackLen,
|
||||
const void *const needle, const size_t needleLen)
|
||||
{
|
||||
#if defined(AURORA_IS_LINUX_DERIVED)
|
||||
return ::memmem(haystack, heystackLen, needle, needleLen);
|
||||
#else
|
||||
if (!haystack)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
if (!haystackLen)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
if (!needle)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
if (!needleLen)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
for (const char *h = (const char *)haystack;
|
||||
haystackLen >= needleLen;
|
||||
++h, --haystackLen)
|
||||
{
|
||||
if (!AuMemcmp(h, needle, needleLen))
|
||||
{
|
||||
return (void *)h;
|
||||
}
|
||||
}
|
||||
|
||||
return {};
|
||||
#endif
|
||||
}
|
Loading…
Reference in New Issue
Block a user