XRootD
XrdOucHashVal.cc File Reference
#include "string.h"
#include "strings.h"
+ Include dependency graph for XrdOucHashVal.cc:

Go to the source code of this file.

Functions

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

Function Documentation

◆ XrdOucHashVal()

unsigned long XrdOucHashVal ( const char *  KeyVal)

Definition at line 35 of file XrdOucHashVal.cc.

36  {extern unsigned long XrdOucHashVal2(const char *, int);
37  return XrdOucHashVal2(KeyVal, strlen(KeyVal));
38  }
unsigned long XrdOucHashVal2(const char *KeyVal, int KeyLen)

References XrdOucHashVal2().

Referenced by XrdOucHash< T >::Add(), XrdOucHash< T >::Del(), and XrdOssSys::Stage_RT().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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 }

Referenced by XrdAccCapability::XrdAccCapability(), XrdAccAccess::Access(), XrdOucN2No2p::pfn2lfn(), XrdAccCapability::Privs(), and XrdOucHashVal().

+ Here is the caller graph for this function: