Files
libucore/src/ucore_elfhash.c
T
2012-10-29 23:07:32 +01:00

21 lines
311 B
C

#include "ucore_hash.h"
uint32_t
uc_elfhash(const char *str, uint32_t len)
{
uint32_t hash = 0;
uint32_t x = 0;
uint32_t i = 0;
for (i = 0; i < len; str++, i++) {
hash = (hash << 4) + (*str);
if ((x = hash & 0xF0000000L) != 0) {
hash ^= (x >> 24);
hash &= ~x;
}
}
return hash;
}