/sstrhash.c (ea188616a23838fd64aceadf9bd596b0b19bb20c) (2441 bytes) (mode 100644) (type blob)
#include "sstrhash.h"
#include <stdint.h>
#include <string.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 |
3646 |
47954500887f51663836b8d7380d90d46122972b |
GNUmakefile |
100644 |
blob |
1313 |
4dc80d23e5c4804173171f9e03724a7d9fff66a1 |
LICENSE |
100644 |
blob |
1431 |
176e50b9b24ded89c009136a2386586cacd5fcd2 |
blocks.c |
100644 |
blob |
284 |
fe2c87b1e497bec19349f6250c1be9552b956e09 |
blocks.h |
100755 |
blob |
428 |
cc6218cbb759cfd1deef9a20b246b8ed7697bd02 |
check.sh |
100755 |
blob |
273 |
b0e5e8c7418adb04f6a7d76e9c011b4ba4ef3092 |
fail.sh |
100644 |
blob |
992 |
9e489fcd1e0200c395567965a394a61869976dc8 |
flake.lock |
100644 |
blob |
1761 |
92d7df0df6f74646b74191e289383000d92aac2f |
flake.nix |
100644 |
blob |
266 |
88a7c9f4c9cfca968c1b863d4fd49131b5c2e175 |
funcdecl.c |
100644 |
blob |
276 |
f409be6b975f0a454de860058f1bf91849f1de96 |
funcdecl.h |
100644 |
blob |
22296 |
c7c6b7f8307c1c88886fa8091c7921ea247c8d75 |
grammar.y |
100644 |
blob |
1684 |
3f87f5c4542560d5ded7bd36438657a5869771ca |
hashtable.c |
100644 |
blob |
501 |
2185dc1cb949f6fa3a1b0985b4caaf7769456156 |
hashtable.h |
100644 |
blob |
7565 |
9a841d9cd5246171bd392cc8ab640e1d84714822 |
main.c |
100644 |
blob |
25131 |
cd6306344da3eab3dbf4a65590480ec4933e714d |
misc.c |
100644 |
blob |
4850 |
900a90d50effac8df3de9cc8359df1055da43c41 |
misc.h |
100644 |
blob |
330 |
92a4597d6df5097c58649391541d54f06b3bda1b |
paramlist.c |
100644 |
blob |
256 |
bb253362ef26a0ea881856aebeb8503fb82646fb |
paramlist.h |
100644 |
blob |
3680 |
0d3a55aa2bd7911e71390008b7723399c094eba1 |
readme.md |
100644 |
blob |
2441 |
ea188616a23838fd64aceadf9bd596b0b19bb20c |
sstrhash.c |
100644 |
blob |
135 |
c5326df74bb15edc131620941e0d4dc25ef2abb4 |
sstrhash.h |
040000 |
tree |
- |
3476d6a9d28667510ca4383a7710925d894b4722 |
tests |
100644 |
blob |
6789 |
6a72ce2103c678f973d5fcc1b36a112c8f305264 |
token.l |
100644 |
blob |
1287 |
753fde490a39a9c775f5565af6ea5e6a8b64d419 |
tree.c |
100644 |
blob |
356 |
d943f2d407216cea33c9931439d6802af7d08ce6 |
tree.h |
100644 |
blob |
2502 |
fee7aee3384745b8f13f8b98870814cc109981b6 |
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