From 344f0b743dd66157af249340e760872fcb2a79d1 Mon Sep 17 00:00:00 2001 From: Andrew Chambers Date: Fri, 17 Jan 2020 17:24:32 +1300 Subject: [PATCH] Make hash api more future proof. --- src/core/util.c | 4 ++-- src/include/janet.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/util.c b/src/core/util.c index 636b89a0..8559ceca 100644 --- a/src/core/util.c +++ b/src/core/util.c @@ -200,9 +200,9 @@ static uint32_t halfsiphash(const uint8_t *in, const size_t inlen, const uint8_t } /* end of siphash */ -static uint8_t hash_key[16] = {0}; +static uint8_t hash_key[JANET_HASH_KEY_SIZE] = {0}; -void janet_init_hash_key(uint8_t new_key[16]) { +void janet_init_hash_key(uint8_t new_key[JANET_HASH_KEY_SIZE]) { memcpy(hash_key, new_key, sizeof(hash_key)); } diff --git a/src/include/janet.h b/src/include/janet.h index 0e5931a7..a2120695 100644 --- a/src/include/janet.h +++ b/src/include/janet.h @@ -1303,7 +1303,8 @@ JANET_API JanetBuffer *janet_pretty(JanetBuffer *buffer, int depth, int flags, J /* Misc */ #ifndef JANET_NO_PRF -JANET_API void janet_init_hash_key(uint8_t key[16]); +#define JANET_HASH_KEY_SIZE 16 +JANET_API void janet_init_hash_key(uint8_t key[JANET_HASH_KEY_SIZE]); #endif JANET_API int janet_equals(Janet x, Janet y); JANET_API int32_t janet_hash(Janet x);