microsoft/onnxruntime-extensions

Public

mirrored from https://github.com/microsoft/onnxruntime-extensionsAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v0.5.0

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

cmake/externals/farmhash/dev/TESTBOILERPLATEHash32

22lines · modecode

1// Hash the concatenation of the given string with itself.
2uint32_t Hash32D(const char* s, size_t len) {
3 char buf[8000];
4 char* ss = len*2 > sizeof(buf) ? (char*)malloc(len*2) : buf;
5 memcpy(ss, s, len);
6 memcpy(ss + len, s, len);
7 uint32_t h = Hash32(ss, len*2);
8 if (ss != buf) free(ss);
9 return h;
10}
11
12// Hash the concatenation of the given string with 3 copies of itself.
13uint32_t Hash32Q(const char* s, size_t len) {
14 char buf[8000];
15 char* ss = len*4 > sizeof(buf) ? (char*)malloc(len*4) : buf;
16 memcpy(ss, s, len);
17 memcpy(ss + len, s, len);
18 memcpy(ss + len*2, ss, len*2);
19 uint32_t h = Hash32(ss, len*4);
20 if (ss != buf) free(ss);
21 return h;
22}