blob: f9b80e42b0da946fcf44b0954c576cb0ffe7b139 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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;
}
|