X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/4769a870917b98723690aa336d12d0656769528b..313093773e81eb89ad3c44b048a79bbcd6e94099:/lunaix-os/includes/lunaix/ds/hstr.h diff --git a/lunaix-os/includes/lunaix/ds/hstr.h b/lunaix-os/includes/lunaix/ds/hstr.h index 4864052..d954103 100644 --- a/lunaix-os/includes/lunaix/ds/hstr.h +++ b/lunaix-os/includes/lunaix/ds/hstr.h @@ -3,23 +3,36 @@ #include +#define HSTR_FULL_HASH 32 + struct hstr { - unsigned int hash; - unsigned int len; - char* value; + u32_t hash; + u32_t len; + const char* value; }; #define HSTR(str, length) \ (struct hstr) \ { \ - .len = length, .value = str \ + .len = (length), .value = (str) \ } +#define HHSTR(str, length, strhash) \ + (struct hstr) \ + { \ + .len = (length), .value = (str), .hash = (strhash) \ + } + +#define HSTR_EQ(str1, str2) ((str1)->hash == (str2)->hash) + inline void -hstr_rehash(struct hstr* hash_str, unsigned int truncate_to) +hstr_rehash(struct hstr* hash_str, u32_t truncate_to) { hash_str->hash = strhash_32(hash_str->value, truncate_to); } +void +hstrcpy(struct hstr* dest, struct hstr* src); + #endif /* __LUNAIX_HSTR_H */