@@ -2394,16 +2394,35 @@ static void XXH_free(void* p) { free(p); }
2394
2394
2395
2395
#endif /* XXH_NO_STDLIB */
2396
2396
2397
- #include < string.h>
2397
+ #ifndef XXH_memcpy
2398
+ /* !
2399
+ * @internal
2400
+ * @brief XXH_memcpy() macro can be redirected at compile time
2401
+ */
2402
+ # include < string.h>
2403
+ # define XXH_memcpy memcpy
2404
+ #endif
2398
2405
2406
+ #ifndef XXH_memset
2399
2407
/* !
2400
2408
* @internal
2401
- * @brief Modify this function to use a different routine than memcpy().
2409
+ * @brief XXH_memset() macro can be redirected at compile time
2402
2410
*/
2403
- static void * XXH_memcpy (void * dest, const void * src, size_t size)
2404
- {
2405
- return memcpy (dest,src,size);
2406
- }
2411
+ # include < string.h>
2412
+ # define XXH_memset memset
2413
+ #endif
2414
+
2415
+ #ifndef XXH_memcmp
2416
+ /* !
2417
+ * @internal
2418
+ * @brief XXH_memcmp() macro can be redirected at compile time
2419
+ * Note: only needed by XXH128.
2420
+ */
2421
+ # include < string.h>
2422
+ # define XXH_memcmp memcmp
2423
+ #endif
2424
+
2425
+
2407
2426
2408
2427
#include < limits.h> /* ULLONG_MAX */
2409
2428
@@ -3224,7 +3243,7 @@ XXH_PUBLIC_API void XXH32_copyState(XXH32_state_t* dstState, const XXH32_state_t
3224
3243
XXH_PUBLIC_API XXH_errorcode XXH32_reset (XXH32_state_t* statePtr, XXH32_hash_t seed)
3225
3244
{
3226
3245
XXH_ASSERT (statePtr != NULL );
3227
- memset (statePtr, 0 , sizeof (*statePtr));
3246
+ XXH_memset (statePtr, 0 , sizeof (*statePtr));
3228
3247
XXH32_initAccs (statePtr->acc , seed);
3229
3248
return XXH_OK;
3230
3249
}
@@ -3721,7 +3740,7 @@ XXH_PUBLIC_API void XXH64_copyState(XXH_NOESCAPE XXH64_state_t* dstState, const
3721
3740
XXH_PUBLIC_API XXH_errorcode XXH64_reset (XXH_NOESCAPE XXH64_state_t* statePtr, XXH64_hash_t seed)
3722
3741
{
3723
3742
XXH_ASSERT (statePtr != NULL );
3724
- memset (statePtr, 0 , sizeof (*statePtr));
3743
+ XXH_memset (statePtr, 0 , sizeof (*statePtr));
3725
3744
XXH64_initAccs (statePtr->acc , seed);
3726
3745
return XXH_OK;
3727
3746
}
@@ -6409,7 +6428,7 @@ XXH3_reset_internal(XXH3_state_t* statePtr,
6409
6428
XXH_ASSERT (offsetof (XXH3_state_t, nbStripesPerBlock) > initStart);
6410
6429
XXH_ASSERT (statePtr != NULL );
6411
6430
/* set members from bufferedSize to nbStripesPerBlock (excluded) to 0 */
6412
- memset ((char *)statePtr + initStart, 0 , initLength);
6431
+ XXH_memset ((char *)statePtr + initStart, 0 , initLength);
6413
6432
statePtr->acc [0 ] = XXH_PRIME32_3;
6414
6433
statePtr->acc [1 ] = XXH_PRIME64_1;
6415
6434
statePtr->acc [2 ] = XXH_PRIME64_2;
@@ -7183,14 +7202,12 @@ XXH_PUBLIC_API XXH128_hash_t XXH3_128bits_digest (XXH_NOESCAPE const XXH3_state_
7183
7202
#endif /* !XXH_NO_STREAM */
7184
7203
/* 128-bit utility functions */
7185
7204
7186
- #include < string.h> /* memcmp, memcpy */
7187
-
7188
7205
/* return : 1 is equal, 0 if different */
7189
7206
/* ! @ingroup XXH3_family */
7190
7207
XXH_PUBLIC_API int XXH128_isEqual (XXH128_hash_t h1, XXH128_hash_t h2)
7191
7208
{
7192
7209
/* note : XXH128_hash_t is compact, it has no padding byte */
7193
- return !(memcmp (&h1, &h2, sizeof (h1)));
7210
+ return !(XXH_memcmp (&h1, &h2, sizeof (h1)));
7194
7211
}
7195
7212
7196
7213
/* This prototype is compatible with stdlib's qsort().
@@ -7274,7 +7291,7 @@ XXH3_generateSecret(XXH_NOESCAPE void* secretBuffer, size_t secretSize, XXH_NOES
7274
7291
{ size_t pos = 0 ;
7275
7292
while (pos < secretSize) {
7276
7293
size_t const toCopy = XXH_MIN ((secretSize - pos), customSeedSize);
7277
- memcpy ((char *)secretBuffer + pos, customSeed, toCopy);
7294
+ XXH_memcpy ((char *)secretBuffer + pos, customSeed, toCopy);
7278
7295
pos += toCopy;
7279
7296
} }
7280
7297
@@ -7299,7 +7316,7 @@ XXH3_generateSecret_fromSeed(XXH_NOESCAPE void* secretBuffer, XXH64_hash_t seed)
7299
7316
XXH_ALIGN (XXH_SEC_ALIGN) xxh_u8 secret[XXH_SECRET_DEFAULT_SIZE];
7300
7317
XXH3_initCustomSecret (secret, seed);
7301
7318
XXH_ASSERT (secretBuffer != NULL );
7302
- memcpy (secretBuffer, secret, XXH_SECRET_DEFAULT_SIZE);
7319
+ XXH_memcpy (secretBuffer, secret, XXH_SECRET_DEFAULT_SIZE);
7303
7320
}
7304
7321
7305
7322
0 commit comments