mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 1427025 - Remove nsCRT::memmem. r=froydnj
This commit is contained in:
parent
73071eec8f
commit
2c25ef1a1c
@ -111,31 +111,6 @@ nsCRT::strcmp(const char16_t* aStr1, const char16_t* aStr2)
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char*
|
||||
nsCRT::memmem(const char* aHaystack, uint32_t aHaystackLen,
|
||||
const char* aNeedle, uint32_t aNeedleLen)
|
||||
{
|
||||
// Sanity checking
|
||||
if (!(aHaystack && aNeedle && aHaystackLen && aNeedleLen &&
|
||||
aNeedleLen <= aHaystackLen)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#ifdef HAVE_MEMMEM
|
||||
return (const char*)::memmem(aHaystack, aHaystackLen, aNeedle, aNeedleLen);
|
||||
#else
|
||||
// No memmem means we need to roll our own. This isn't really optimized
|
||||
// for performance ... if that becomes an issue we can take some inspiration
|
||||
// from the js string compare code in jsstr.cpp
|
||||
for (uint32_t i = 0; i < aHaystackLen - aNeedleLen; i++) {
|
||||
if (!memcmp(aHaystack + i, aNeedle, aNeedleLen)) {
|
||||
return aHaystack + i;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// This should use NSPR but NSPR isn't exporting its PR_strtoll function
|
||||
// Until then...
|
||||
int64_t
|
||||
|
@ -85,12 +85,6 @@ public:
|
||||
/// Like strcmp except for ucs2 strings
|
||||
static int32_t strcmp(const char16_t* aStr1, const char16_t* aStr2);
|
||||
|
||||
// The GNU libc has memmem, which is strstr except for binary data
|
||||
// This is our own implementation that uses memmem on platforms
|
||||
// where it's available.
|
||||
static const char* memmem(const char* aHaystack, uint32_t aHaystackLen,
|
||||
const char* aNeedle, uint32_t aNeedleLen);
|
||||
|
||||
// String to longlong
|
||||
static int64_t atoll(const char* aStr);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user