feat: serial device interfacing
[lunaix-os.git] / lunaix-os / includes / lunaix / ds / hstr.h
index 5fb84d94bc36f0354b0088d761f53ccea0c8df49..d954103ce44f797024133d41f2189e37c97bc4ca 100644 (file)
@@ -7,9 +7,9 @@
 
 struct hstr
 {
-    unsigned int hash;
-    unsigned int len;
-    char* value;
+    u32_t hash;
+    u32_t len;
+    const char* value;
 };
 
 #define HSTR(str, length)                                                      \
@@ -18,12 +18,21 @@ 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)
+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 */