]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Add legacy XXH32_init.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 21 Feb 2015 18:30:09 +0000 (18:30 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 21 Feb 2015 18:30:09 +0000 (18:30 +0000)
contrib/xxhash/xxhash.c
contrib/xxhash/xxhash.h

index 24a64b5f808ca20b895a18367004b70e4a3db528..15064f9fb673f24fe157551c001b8c8c6b04ddad 100644 (file)
@@ -531,6 +531,15 @@ XXH32_state_t* XXH32_createState(void)
     XXH_STATIC_ASSERT(sizeof(XXH32_state_t) >= sizeof(XXH_istate32_t));   // A compilation error here means XXH32_state_t is not large enough
     return (XXH32_state_t*)XXH_malloc(sizeof(XXH32_state_t));
 }
+
+void* XXH32_init (unsigned seed)
+{
+       XXH32_state_t *st = XXH32_createState();
+       XXH32_reset(st, seed);
+
+       return st;
+}
+
 XXH_errorcode XXH32_freeState(XXH32_state_t* statePtr)
 {
     XXH_free(statePtr);
@@ -717,6 +726,7 @@ FORCE_INLINE U32 XXH32_digest_endian (const XXH32_state_t* state_in, XXH_endiane
     h32 *= PRIME32_3;
     h32 ^= h32 >> 16;
 
+    XXH32_freeState((XXH32_state_t *)state_in);
     return h32;
 }
 
@@ -911,6 +921,7 @@ FORCE_INLINE U64 XXH64_digest_endian (const XXH64_state_t* state_in, XXH_endiane
     h64 *= PRIME64_3;
     h64 ^= h64 >> 32;
 
+    XXH64_freeState((XXH64_state_t *)state_in);
     return h64;
 }
 
index 55b45015a447e44db6840aa679b435faf90abe3f..4a41bfbf8cb673a2f1c54f2b7bfd5c8881ea00f1 100644 (file)
@@ -110,6 +110,12 @@ States must then be initialized using XXHnn_reset() before first use.
 If you prefer dynamic allocation, please refer to functions below.
 */
 
+/*
+ * !!!
+ * Rspamd specific: we use the legacy method to free state when digest is obtained
+ * !!!
+ */
+void * XXH32_init (unsigned seed);
 XXH32_state_t* XXH32_createState(void);
 XXH_errorcode  XXH32_freeState(XXH32_state_t* statePtr);