Move hash to top of chat.h
parent
83a8952cf5
commit
af87b4e68d
24
chat.h
24
chat.h
|
@ -58,6 +58,18 @@ static inline size_t idFor(const char *name) {
|
||||||
return idNext++;
|
return idNext++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern uint32_t hashInit;
|
||||||
|
static inline enum Color hash(const char *str) {
|
||||||
|
if (*str == '~') str++;
|
||||||
|
uint32_t hash = hashInit;
|
||||||
|
for (; *str; ++str) {
|
||||||
|
hash = (hash << 5) | (hash >> 27);
|
||||||
|
hash ^= *str;
|
||||||
|
hash *= 0x27220A95;
|
||||||
|
}
|
||||||
|
return 2 + hash % 74;
|
||||||
|
}
|
||||||
|
|
||||||
#define ENUM_CAP \
|
#define ENUM_CAP \
|
||||||
X("extended-join", CapExtendedJoin) \
|
X("extended-join", CapExtendedJoin) \
|
||||||
X("sasl", CapSASL) \
|
X("sasl", CapSASL) \
|
||||||
|
@ -195,18 +207,6 @@ int getopt_config(
|
||||||
const char *optstring, const struct option *longopts, int *longindex
|
const char *optstring, const struct option *longopts, int *longindex
|
||||||
);
|
);
|
||||||
|
|
||||||
extern uint32_t hashInit;
|
|
||||||
static inline enum Color hash(const char *str) {
|
|
||||||
if (*str == '~') str++;
|
|
||||||
uint32_t hash = hashInit;
|
|
||||||
for (; *str; ++str) {
|
|
||||||
hash = (hash << 5) | (hash >> 27);
|
|
||||||
hash ^= *str;
|
|
||||||
hash *= 0x27220A95;
|
|
||||||
}
|
|
||||||
return 2 + hash % 74;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Defined in libcrypto if missing from libc:
|
// Defined in libcrypto if missing from libc:
|
||||||
void explicit_bzero(void *b, size_t len);
|
void explicit_bzero(void *b, size_t len);
|
||||||
#ifndef strlcat
|
#ifndef strlcat
|
||||||
|
|
Loading…
Reference in New Issue