From c846952cbfbd25978f3a320112a59071d0c6b820 Mon Sep 17 00:00:00 2001 From: amir Date: Sun, 8 Mar 2026 10:47:18 +0100 Subject: [PATCH] forcing xxhash to use the stack instead of the heap --- platform_windows.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/platform_windows.c b/platform_windows.c index a0f25d6..290d4f4 100644 --- a/platform_windows.c +++ b/platform_windows.c @@ -388,18 +388,17 @@ static void xxh3_hash_file_stream(const char *path, char *out_hex) { return; } XXH128_hash_t h; - XXH3_state_t *state = XXH3_createState(); - XXH3_128bits_reset(state); + XXH3_state_t state; + XXH3_128bits_reset(&state); BYTE *buf = (BYTE *)malloc(READ_BLOCK); DWORD read = 0; BOOL ok; 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); } - h = XXH3_128bits_digest(state); - XXH3_freeState(state); + h = XXH3_128bits_digest(&state); CloseHandle(hFile); free(buf); snprintf(out_hex, HASH_STRLEN, "%016llx%016llx", (unsigned long long)h.high64,