XRootD
Loading...
Searching...
No Matches
XrdAccCapability.cc File Reference
+ Include dependency graph for XrdAccCapability.cc:

Go to the source code of this file.

Functions

unsigned long XrdOucHashVal2 (const char *KeyVal, int KeyLen)
 

Function Documentation

◆ XrdOucHashVal2()

unsigned long XrdOucHashVal2 ( const char *  KeyVal,
int  KeyLen 
)

Definition at line 40 of file XrdOucHashVal.cc.

41{ int j;
42 unsigned long *lp, lword, hval = 0;
43 int hl = sizeof(hval);
44
45// If name is shorter than the hash length, use the name.
46//
47 if (KeyLen <= hl)
48 {memcpy(&hval, KeyVal, (size_t)KeyLen);
49 return hval;
50 }
51
52// Compute the length of the name and develop starting hash.
53//
54 hval = KeyLen;
55 j = KeyLen % hl; KeyLen /= hl;
56 if (j)
57 {memcpy(&lword, KeyVal, (size_t)hl);
58 hval ^= lword;
59 }
60 lp = (unsigned long *)&KeyVal[j];
61
62// Compute and return the full hash.
63//
64 while(KeyLen--)
65 {memcpy(&lword, lp++, (size_t)hl);
66 hval ^= lword;
67 }
68 return (hval ? hval : 1);
69}