git://scm.lunaixsky.com
/
lunaix-os.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Second Extended Filesystem (ext2) and other improvements (#33)
[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
index 48640529680ce270fbb68c0c41580acc31337be9..f43a6db24904d443469c281e726394832d0b6584 100644
(file)
--- a/
lunaix-os/includes/lunaix/ds/hstr.h
+++ b/
lunaix-os/includes/lunaix/ds/hstr.h
@@
-1,25
+1,42
@@
#ifndef __LUNAIX_HSTR_H
#define __LUNAIX_HSTR_H
#ifndef __LUNAIX_HSTR_H
#define __LUNAIX_HSTR_H
-#include <lib/hash.h>
+#include <klibc/hash.h>
+
+#define HSTR_FULL_HASH 32
struct hstr
{
struct hstr
{
- u
nsigned in
t hash;
- u
nsigned in
t len;
- char* value;
+ u
32_
t hash;
+ u
32_
t len;
+ c
onst c
har* value;
};
#define HSTR(str, length) \
(struct hstr) \
{ \
};
#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)
+
+#define HSTR_VAL(hstr) ((hstr).value)
+#define HSTR_LEN(hstr) ((hstr).len)
+#define HSTR_HASH(hstr) ((hstr).hash)
+
inline void
inline void
-hstr_rehash(struct hstr* hash_str, u
nsigned in
t truncate_to)
+hstr_rehash(struct hstr* hash_str, u
32_
t truncate_to)
{
hash_str->hash = strhash_32(hash_str->value, truncate_to);
}
{
hash_str->hash = strhash_32(hash_str->value, truncate_to);
}
+void
+hstrcpy(struct hstr* dest, struct hstr* src);
+
#endif /* __LUNAIX_HSTR_H */
#endif /* __LUNAIX_HSTR_H */