pjwhash: char* to void*

This commit is contained in:
2022-12-17 11:27:40 +01:00
parent 3f5b282883
commit bd2548fca9
2 changed files with 5 additions and 4 deletions

View File

@@ -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;

View File

@@ -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 */