/sstrhash.c (2da92786104975ea22a86ebfa36e70351bd5503f) (2419 bytes) (mode 100644) (type blob)
#include "sstrhash.h"
#include <stdint.h>
#define mix(a,b,c) \
{ \
a -= b; a -= c; a ^= (c>>13); \
b -= c; b -= a; b ^= (a<<8); \
c -= a; c -= b; c ^= (b>>13); \
a -= b; a -= c; a ^= (c>>12); \
b -= c; b -= a; b ^= (a<<16); \
c -= a; c -= b; c ^= (b>>5); \
a -= b; a -= c; a ^= (c>>3); \
b -= c; b -= a; b ^= (a<<10); \
c -= a; c -= b; c ^= (b>>15); \
}
static uint32_t hash(k, length, initval)
register uint8_t *k; /* the key */
register uint32_t length; /* the length of the key */
register uint32_t initval; /* the previous hash, or an arbitrary value */
{
register uint32_t a,b,c,len;
/* Set up the internal state */
len = length;
a = b = 0x9e3779b9; /* the golden ratio; an arbitrary value */
c = initval; /* the previous hash value */
/*---------------------------------------- handle most of the key */
while (len >= 12)
{
a += (k[0] +((uint32_t)k[1]<<8) +((uint32_t)k[2]<<16) +((uint32_t)k[3]<<24));
b += (k[4] +((uint32_t)k[5]<<8) +((uint32_t)k[6]<<16) +((uint32_t)k[7]<<24));
c += (k[8] +((uint32_t)k[9]<<8) +((uint32_t)k[10]<<16)+((uint32_t)k[11]<<24));
mix(a,b,c);
k += 12; len -= 12;
}
/*------------------------------------- handle the last 11 bytes */
c += length;
switch(len) /* all the case statements fall through */
{
case 11: c+=((uint32_t)k[10]<<24);
case 10: c+=((uint32_t)k[9]<<16);
case 9 : c+=((uint32_t)k[8]<<8);
/* the first byte of c is reserved for the length */
case 8 : b+=((uint32_t)k[7]<<24);
case 7 : b+=((uint32_t)k[6]<<16);
case 6 : b+=((uint32_t)k[5]<<8);
case 5 : b+=k[4];
case 4 : a+=((uint32_t)k[3]<<24);
case 3 : a+=((uint32_t)k[2]<<16);
case 2 : a+=((uint32_t)k[1]<<8);
case 1 : a+=k[0];
/* case 0: nothing left to add */
}
mix(a,b,c);
/*-------------------------------------------- report the result */
return c;
}
#undef mix
uint32_t hashfunc(uint8_t *key){
return hash(key, strlen(key), 0);
}
uint32_t SStrHash2(uint8_t *key){
uint8_t buff[0x400];
uint32_t len=0;
while(*key){
if(*key <'a' || *key>'z'){
if(*key == '/'){
buff[len] = '\\';
}else{
buff[len] = *key;
}
}else{
buff[len] = *key - 0x20;
}
key++;
len++;
}
return hash(buff, len, 0);
}
Mode |
Type |
Size |
Ref |
File |
100644 |
blob |
170 |
28f83f8deb57bbc09c713a866975355fd9225827 |
.gitignore |
100644 |
blob |
48 |
3bfb16e6c32903fb8e4db429b412ee6e8ef23a14 |
AUTHORS |
100644 |
blob |
3557 |
a62ad00cdae7cd8a72c80d1d6ce2796e53b6d58c |
GNUmakefile |
100644 |
blob |
1313 |
4dc80d23e5c4804173171f9e03724a7d9fff66a1 |
LICENSE |
100644 |
blob |
1431 |
176e50b9b24ded89c009136a2386586cacd5fcd2 |
blocks.c |
100644 |
blob |
282 |
7e063255643b647d598dadd7832458b24af8999d |
blocks.h |
100755 |
blob |
428 |
cc6218cbb759cfd1deef9a20b246b8ed7697bd02 |
check.sh |
100755 |
blob |
273 |
b0e5e8c7418adb04f6a7d76e9c011b4ba4ef3092 |
fail.sh |
100644 |
blob |
266 |
88a7c9f4c9cfca968c1b863d4fd49131b5c2e175 |
funcdecl.c |
100644 |
blob |
276 |
f409be6b975f0a454de860058f1bf91849f1de96 |
funcdecl.h |
100644 |
blob |
22316 |
d468d760ea15a1302b551138f6f2e51bed797982 |
grammar.y |
100644 |
blob |
1684 |
3f87f5c4542560d5ded7bd36438657a5869771ca |
hashtable.c |
100644 |
blob |
501 |
2185dc1cb949f6fa3a1b0985b4caaf7769456156 |
hashtable.h |
100644 |
blob |
6470 |
e50f3c6407908ffbd851b8de72229baf649c3e64 |
main.c |
100644 |
blob |
24837 |
9de9d46a2eb5f8cc19b170d035009e064f9c1ca3 |
misc.c |
100644 |
blob |
4680 |
d0822164a1e66dfe614ebbfa8cb24bd904d4fe00 |
misc.h |
100644 |
blob |
330 |
92a4597d6df5097c58649391541d54f06b3bda1b |
paramlist.c |
100644 |
blob |
256 |
bb253362ef26a0ea881856aebeb8503fb82646fb |
paramlist.h |
100644 |
blob |
3680 |
0d3a55aa2bd7911e71390008b7723399c094eba1 |
readme.md |
100644 |
blob |
2419 |
2da92786104975ea22a86ebfa36e70351bd5503f |
sstrhash.c |
100644 |
blob |
142 |
554d4f7e4b94fb54dc58105adfc9cb4afac6887a |
sstrhash.h |
040000 |
tree |
- |
353c2b19d039ebd6ba45c6cfa887ee3975b60ace |
tests |
100644 |
blob |
6881 |
5b807517d3865b302cbde97aa949347c60a27a1d |
token.l |
100644 |
blob |
1265 |
7fe0fbe5c32390cfd7a0629649fccc5899738aeb |
tree.c |
100644 |
blob |
356 |
d943f2d407216cea33c9931439d6802af7d08ce6 |
tree.h |
100644 |
blob |
2363 |
84b80d18c7006a12bf02635dcd3ad47f459f6a61 |
typeandname.c |
100644 |
blob |
914 |
c7c2ecbf5459c7cb80bd2661e6ca78c32a780e10 |
typeandname.h |
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"
Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/vrtc/pjass
Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/vrtc/pjass
Clone this repository using git:
git clone git://git.rocketgit.com/user/vrtc/pjass
You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a
merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main