зеркало из https://github.com/mozilla/gecko-dev.git
Bug 695515 - Remove last use of memmem. r=khuey
This commit is contained in:
Родитель
1c9029e5ec
Коммит
6707836f9a
|
@ -3347,7 +3347,7 @@ esac
|
|||
|
||||
_SAVE_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS -D_GNU_SOURCE"
|
||||
AC_CHECK_FUNCS(dladdr memmem)
|
||||
AC_CHECK_FUNC(dladdr)
|
||||
CFLAGS="$_SAVE_CFLAGS"
|
||||
|
||||
if test ! "$GNU_CXX"; then
|
||||
|
|
|
@ -159,28 +159,6 @@ PRInt32 nsCRT::strncmp(const PRUnichar* s1, const PRUnichar* s2, PRUint32 n) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
const char* nsCRT::memmem(const char* haystack, PRUint32 haystackLen,
|
||||
const char* needle, PRUint32 needleLen)
|
||||
{
|
||||
// Sanity checking
|
||||
if (!(haystack && needle && haystackLen && needleLen &&
|
||||
needleLen <= haystackLen))
|
||||
return NULL;
|
||||
|
||||
#ifdef HAVE_MEMMEM
|
||||
return (const char*)::memmem(haystack, haystackLen, needle, needleLen);
|
||||
#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 (PRInt32 i = 0; i < haystackLen - needleLen; i++) {
|
||||
if (!memcmp(haystack + i, needle, needleLen))
|
||||
return haystack + i;
|
||||
}
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PRUnichar* nsCRT::strdup(const PRUnichar* str)
|
||||
{
|
||||
PRUint32 len = nsCRT::strlen(str);
|
||||
|
|
|
@ -210,12 +210,6 @@ public:
|
|||
static PRInt32 strncmp(const PRUnichar* s1, const PRUnichar* s2,
|
||||
PRUint32 aMaxLen);
|
||||
|
||||
// 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* haystack, PRUint32 haystackLen,
|
||||
const char* needle, PRUint32 needleLen);
|
||||
|
||||
// You must use nsCRT::free(PRUnichar*) to free memory allocated
|
||||
// by nsCRT::strdup(PRUnichar*).
|
||||
static PRUnichar* strdup(const PRUnichar* str);
|
||||
|
|
Загрузка…
Ссылка в новой задаче