зеркало из https://github.com/mozilla/gecko-dev.git
Null protecting hashing code. 96322. r=dp@netscape.com sr=alecf@netscape.com.
This commit is contained in:
Родитель
7490c158ee
Коммит
902facd5e3
|
@ -273,6 +273,8 @@ PRUint32 nsCRT::HashCode(const char* str, PRUint32* resultingStrLen)
|
||||||
PRUint32 h = 0;
|
PRUint32 h = 0;
|
||||||
const char* s = str;
|
const char* s = str;
|
||||||
|
|
||||||
|
if (!str) return h;
|
||||||
|
|
||||||
unsigned char c;
|
unsigned char c;
|
||||||
while ( (c = *s++) )
|
while ( (c = *s++) )
|
||||||
h = (h>>28) ^ (h<<4) ^ c;
|
h = (h>>28) ^ (h<<4) ^ c;
|
||||||
|
@ -287,6 +289,8 @@ PRUint32 nsCRT::HashCode(const PRUnichar* str, PRUint32* resultingStrLen)
|
||||||
PRUint32 h = 0;
|
PRUint32 h = 0;
|
||||||
const PRUnichar* s = str;
|
const PRUnichar* s = str;
|
||||||
|
|
||||||
|
if (!str) return h;
|
||||||
|
|
||||||
{
|
{
|
||||||
PRUint16 W1 = 0; // the first UTF-16 word in a two word tuple
|
PRUint16 W1 = 0; // the first UTF-16 word in a two word tuple
|
||||||
PRUint32 U = 0; // the current char as UCS-4
|
PRUint32 U = 0; // the current char as UCS-4
|
||||||
|
|
Загрузка…
Ссылка в новой задаче