use ZSTD_memset()

for better portability on Linux kernel
This commit is contained in:
Yann Collet
2024-10-23 11:50:56 -07:00
parent 586ca96fec
commit e2d7d08888
+10 -6
View File
@@ -39,13 +39,15 @@ typedef struct {
static FingerPrint pastEvents; static FingerPrint pastEvents;
static FingerPrint newEvents; static FingerPrint newEvents;
static void initStats(void) { static void initStats(void)
memset(&pastEvents, 0, sizeof(pastEvents)); {
memset(&newEvents, 0, sizeof(newEvents)); ZSTD_memset(&pastEvents, 0, sizeof(pastEvents));
ZSTD_memset(&newEvents, 0, sizeof(newEvents));
} }
/* ==================================== */ /* ==================================== */
static void addToFingerprint(FingerPrint* fp, const void* src, size_t s) { static void addToFingerprint(FingerPrint* fp, const void* src, size_t s)
{
const char* p = src; const char* p = src;
size_t limit = s - HASHLENGTH + 1; size_t limit = s - HASHLENGTH + 1;
size_t n; size_t n;
@@ -56,14 +58,16 @@ static void addToFingerprint(FingerPrint* fp, const void* src, size_t s) {
fp->nbEvents += limit; fp->nbEvents += limit;
} }
static void recordFingerprint(FingerPrint *fp, const void *src, size_t s) { static void recordFingerprint(FingerPrint* fp, const void* src, size_t s)
{
memset(fp, 0, sizeof(*fp)); memset(fp, 0, sizeof(*fp));
addToFingerprint(fp, src, s); addToFingerprint(fp, src, s);
} }
static S64 abs64(S64 i) { return (i < 0) ? -i : i; } static S64 abs64(S64 i) { return (i < 0) ? -i : i; }
static S64 fpDistance(const FingerPrint *fp1, const FingerPrint *fp2) { static S64 fpDistance(const FingerPrint* fp1, const FingerPrint* fp2)
{
S64 distance = 0; S64 distance = 0;
size_t n; size_t n;
for (n = 0; n < HASHTABLESIZE; n++) { for (n = 0; n < HASHTABLESIZE; n++) {