diff options
Diffstat (limited to 'src/strview.c')
-rw-r--r-- | src/strview.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/strview.c b/src/strview.c new file mode 100644 index 0000000..f9b80e4 --- /dev/null +++ b/src/strview.c @@ -0,0 +1,23 @@ +#include <string.h> + +#include "strview.h" +#include "types.h" + +uint64_t +strview_hash(struct strview sv) +{ + uint64_t h = 0x100; + for (size_t i = 0; i < sv.len; i++) { + h ^= sv.p[i]; + h *= 1111111111111111111u; + } + return h; +} + +uchar * +svtocstr(uchar *dst, struct strview src) +{ + memcpy(dst, src.p, src.len); + dst[src.len] = 0; + return dst; +} |