forked from amir/filehasher
forcing xxhash to use the stack instead of the heap
This commit is contained in:
@@ -388,18 +388,17 @@ static void xxh3_hash_file_stream(const char *path, char *out_hex) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
XXH128_hash_t h;
|
XXH128_hash_t h;
|
||||||
XXH3_state_t *state = XXH3_createState();
|
XXH3_state_t state;
|
||||||
XXH3_128bits_reset(state);
|
XXH3_128bits_reset(&state);
|
||||||
|
|
||||||
BYTE *buf = (BYTE *)malloc(READ_BLOCK);
|
BYTE *buf = (BYTE *)malloc(READ_BLOCK);
|
||||||
DWORD read = 0;
|
DWORD read = 0;
|
||||||
BOOL ok;
|
BOOL ok;
|
||||||
while (ReadFile(hFile, buf, READ_BLOCK, &read, NULL) && read > 0) {
|
while (ReadFile(hFile, buf, READ_BLOCK, &read, NULL) && read > 0) {
|
||||||
XXH3_128bits_update(state, buf, (size_t)read);
|
XXH3_128bits_update(&state, buf, (size_t)read);
|
||||||
atomic_fetch_add(&g_bytes_processed, (uint64_t)read);
|
atomic_fetch_add(&g_bytes_processed, (uint64_t)read);
|
||||||
}
|
}
|
||||||
h = XXH3_128bits_digest(state);
|
h = XXH3_128bits_digest(&state);
|
||||||
XXH3_freeState(state);
|
|
||||||
CloseHandle(hFile);
|
CloseHandle(hFile);
|
||||||
free(buf);
|
free(buf);
|
||||||
snprintf(out_hex, HASH_STRLEN, "%016llx%016llx", (unsigned long long)h.high64,
|
snprintf(out_hex, HASH_STRLEN, "%016llx%016llx", (unsigned long long)h.high64,
|
||||||
|
|||||||
Reference in New Issue
Block a user