| 1 |
|
| #include "EXTERN.h" |
| 2 |
|
| #include "perl.h" |
| 3 |
|
| #include "XSUB.h" |
| 4 |
|
| #include "ppport.h" |
| 5 |
|
| |
| 6 |
|
| MODULE = Algorithm::StringHash::FromCSharp35::XS PACKAGE = Algorithm::StringHash::FromCSharp35::XS |
| 7 |
|
| |
| 8 |
|
| unsigned int GetHashCode(const char * str) |
| 9 |
|
| CODE: |
| 10 |
3 |
| unsigned int num = 0x15051505; |
| 11 |
3 |
| unsigned int num2 = num; |
| 12 |
3 |
| int length=strlen(str); |
| 13 |
|
| |
| 14 |
3 |
| int new_length = length + ( 8 - length % 8) + 128; |
| 15 |
3 |
| char chPtr[new_length]; |
| 16 |
3 |
| memset(chPtr,0,new_length); |
| 17 |
3 |
| strcpy(chPtr,str); |
| 18 |
|
| |
| 19 |
3 |
| unsigned int * numPtr = (unsigned int *)chPtr; |
| 20 |
3 |
| int i=0; |
| 21 |
11 |
▶ | for(i=length;i>0;i-=4) |
Branch: 1 branch
| Branch | True | False | Total |
| for(i=length;i>0;i-=4) |
10 |
1 |
11 |
|
| 22 |
|
| { |
| 23 |
10 |
| num = (((num << 5) + num) + (num >> 0x1b)) ^ numPtr[0]; |
| 24 |
10 |
▶ | if(i<=2) break; |
Branch: 1 branch
| Branch | True | False | Total |
| if(i<=2) break; |
2 |
8 |
10 |
|
| 25 |
8 |
| num2=(((num2 << 5) + num2) + (num2 >> 0x1b)) ^ numPtr[1]; |
| 26 |
8 |
| numPtr+=2; |
| 27 |
|
| } |
| 28 |
3 |
| unsigned int ret = (num + (num2 * 0x5d588b65)); |
| 29 |
3 |
▶ | RETVAL = ret; |
Branch: 1 branch
| Branch | True | False | Total |
| RETVAL = ret; |
0 |
3 |
3 |
|
| 30 |
|
| OUTPUT: |
| 31 |
|
| RETVAL |