From dc4e356edbba4cd8b184d30a836edf5624b6246c Mon Sep 17 00:00:00 2001 From: Alexandre Bruyelles Date: Fri, 17 Nov 2023 12:48:46 +0100 Subject: [PATCH] csum: xxhash: make finish_running_checksum's digest optional If NULL is passed, then the function can be used to free the structure without returning the digest. Signed-off-by: Alexandre Bruyelles --- csum-xxhash.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/csum-xxhash.c b/csum-xxhash.c index 1ae87ca9c781..fd00e56ff6a1 100644 --- a/csum-xxhash.c +++ b/csum-xxhash.c @@ -64,8 +64,10 @@ static void xxhash_finish_running_checksum(struct running_checksum *_c, XXH128_hash_t hash = XXH3_128bits_digest(c->state); - ((uint64_t*)digest)[0] = hash.low64; - ((uint64_t*)digest)[1] = hash.high64; + if (digest) { + ((uint64_t*)digest)[0] = hash.low64; + ((uint64_t*)digest)[1] = hash.high64; + } XXH3_freeState(c->state); }