X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/5fc669295655ec0eea7722aa4a48921dc6b700ec..9daf4fcdae88f72af60aeb0c7722841af02233d4:/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 5fb84d9..77096aa 100644 --- a/lunaix-os/includes/lunaix/ds/hstr.h +++ b/lunaix-os/includes/lunaix/ds/hstr.h @@ -1,7 +1,7 @@ #ifndef __LUNAIX_HSTR_H #define __LUNAIX_HSTR_H -#include +#include #define HSTR_FULL_HASH 32 @@ -9,7 +9,7 @@ struct hstr { unsigned int hash; unsigned int len; - char* value; + const char* value; }; #define HSTR(str, length) \ @@ -18,12 +18,25 @@ struct hstr .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) +#define HSTR_VAL(hstr) ((hstr).value) +#define HSTR_LEN(hstr) ((hstr).len) +#define HSTR_HASH(hstr) ((hstr).hash) + +static inline void +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 */