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 )
extern

Definition at line 57 of file XrdOucHashVal.cc.

58{ int j;
59 const char *cp;
60 unsigned long hval = 0;
61 int hl = sizeof(hval);
62
63// If name is shorter than the hash length, use the name.
64//
65 if (KeyLen <= hl) return LoadWord(KeyVal, (size_t)KeyLen);
66
67// Compute the length of the name and develop starting hash.
68//
69 hval = KeyLen;
70 j = KeyLen % hl; KeyLen /= hl;
71 if (j) hval ^= LoadWord(KeyVal);
72 cp = &KeyVal[j];
73
74// Compute and return the full hash. The key is walked with a byte pointer
75// since it is not aligned for unsigned long; LoadWord() does the unaligned
76// load, and the word arithmetic happens on the copy.
77//
78 while(KeyLen--)
79 {hval ^= LoadWord(cp);
80 cp += hl;
81 }
82 return (hval ? hval : 1);
83}