X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ucw%2Fhashfunc.c;h=d92b681ee6bbdc667d96d9bc23dd258df6d25063;hb=959566090f98dd31eaa67d3d5959b641e5fe902b;hp=ada2a43f22f920856571fd2fff98c95eaac01985;hpb=fa7aa6d9457616ce28f97c83eaa616d0ff276870;p=libucw.git diff --git a/ucw/hashfunc.c b/ucw/hashfunc.c index ada2a43f..d92b681e 100644 --- a/ucw/hashfunc.c +++ b/ucw/hashfunc.c @@ -20,29 +20,29 @@ #define SHIFT_BITS 7 /* A bit-mask which clears higher bytes than a given threshold. */ -static uns mask_higher_bits[sizeof(uns)]; +static uint mask_higher_bits[sizeof(uint)]; static void CONSTRUCTOR hashfunc_init(void) { - uns i, j; + uint i, j; byte *str; - for (i=0; i= sizeof(uns)) + const uint *u = (const uint *) buf; + uint hash = 0; + while (len >= sizeof(uint)) { hash = ROL(hash, SHIFT_BITS) ^ *u++; - len -= sizeof(uns); + len -= sizeof(uint); } hash = ROL(hash, SHIFT_BITS) ^ (*u & mask_higher_bits[len]); return hash; } #ifndef CPU_ALLOW_UNALIGNED -uns +uint str_len(const char *str) { - uns shift = UNALIGNED_PART(str, uns); + uint shift = UNALIGNED_PART(str, uint); if (!shift) return str_len_aligned(str); else { - uns i; - shift = sizeof(uns) - shift; + uint i; + shift = sizeof(uint) - shift; for (i=0; i