feat: vfs - path walking and dnode caching.
[lunaix-os.git] / 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
new file mode 100644 (file)
index 0000000..4864052
--- /dev/null
@@ -0,0 +1,25 @@
+#ifndef __LUNAIX_HSTR_H
+#define __LUNAIX_HSTR_H
+
+#include <lib/hash.h>
+
+struct hstr
+{
+    unsigned int hash;
+    unsigned int len;
+    char* value;
+};
+
+#define HSTR(str, length)                                                      \
+    (struct hstr)                                                              \
+    {                                                                          \
+        .len = length, .value = str                                            \
+    }
+
+inline void
+hstr_rehash(struct hstr* hash_str, unsigned int truncate_to)
+{
+    hash_str->hash = strhash_32(hash_str->value, truncate_to);
+}
+
+#endif /* __LUNAIX_HSTR_H */