blob: 3ed9274bf151683b95d4da5e718aba01912bb2d9 (
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
24
|
#include <inttypes.h>
#include <string.h>
#include "common.h"
#include "strview.h"
#include "types.h"
uint64_t
strview_hash(strview_t sv)
{
uint64_t h = 0x100;
for (size_t i = 0; likely(i < sv.len); i++) {
h ^= sv.p[i];
h *= UINT64_C(1111111111111111111);
}
return h;
}
uchar *
svtocstr(uchar *dst, strview_t src)
{
((uchar *)memcpy(dst, src.p, src.len))[src.len] = 0;
return dst;
}
|