pjwhash: char* to void*
This commit is contained in:
@@ -24,12 +24,13 @@
|
|||||||
#define _pjw_inline static inline
|
#define _pjw_inline static inline
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
_pjw_inline unsigned int pjwhash(const char* str, uint length)
|
_pjw_inline unsigned int pjwhash(const void* key, uint length)
|
||||||
{
|
{
|
||||||
uint hash = 0, high;
|
uint hash = 0, high;
|
||||||
|
const u8 *k = key;
|
||||||
|
|
||||||
for (uint i = 0; i < length; ++str, ++i) {
|
for (uint i = 0; i < length; ++k, ++i) {
|
||||||
hash = (hash << ONE_EIGHTH) + *str;
|
hash = (hash << ONE_EIGHTH) + *k;
|
||||||
high = hash & HIGH_BITS;
|
high = hash & HIGH_BITS;
|
||||||
if (high != 0) {
|
if (high != 0) {
|
||||||
hash ^= high >> THREE_QUARTERS;
|
hash ^= high >> THREE_QUARTERS;
|
||||||
|
@@ -15,6 +15,6 @@
|
|||||||
|
|
||||||
#include "bits.h"
|
#include "bits.h"
|
||||||
|
|
||||||
extern unsigned int pjwhash(const char* str, uint length);
|
extern unsigned int pjwhash (const void* key, uint length)
|
||||||
|
|
||||||
#endif /* _PJWHASH_H */
|
#endif /* _PJWHASH_H */
|
||||||
|
Reference in New Issue
Block a user