From b22caa812daea64da64041d094b755298e04f04b Mon Sep 17 00:00:00 2001 From: Tim Wojtulewicz Date: Fri, 6 Jun 2025 09:08:44 -0700 Subject: [PATCH] Move initialization of RandTest members to header --- src/RandTest.cc | 10 ---------- src/RandTest.h | 24 +++++++++++++++++------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/RandTest.cc b/src/RandTest.cc index 48842ddaab..c97c586d02 100644 --- a/src/RandTest.cc +++ b/src/RandTest.cc @@ -29,16 +29,6 @@ constexpr double RT_INCIRC = 281474943156225.0; namespace zeek::detail { -RandTest::RandTest() { - totalc = 0; - mp = 0; - sccfirst = 1; - inmont = mcount = 0; - cexp = montex = montey = montepi = sccu0 = scclast = scct1 = scct2 = scct3 = 0.0; - - memset(ccount, 0, sizeof(ccount)); -} - void RandTest::add(const void* buf, int bufl) { const unsigned char* bp = static_cast(buf); int oc; diff --git a/src/RandTest.h b/src/RandTest.h index f422cdbbe3..29a1e89944 100644 --- a/src/RandTest.h +++ b/src/RandTest.h @@ -16,20 +16,30 @@ namespace detail { class RandTest { public: - RandTest(); void add(const void* buf, int bufl); void end(double* r_ent, double* r_chisq, double* r_mean, double* r_montepicalc, double* r_scc); private: friend class zeek::EntropyVal; - int64_t ccount[256]; /* Bins to count occurrences of values */ - int64_t totalc; /* Total bytes counted */ - int mp; - int sccfirst; + int64_t ccount[256] = {0}; /* Bins to count occurrences of values */ + int64_t totalc = 0; /* Total bytes counted */ + int mp = 0; + int sccfirst = 1; unsigned int monte[RT_MONTEN] = {0}; - int64_t inmont, mcount; - double cexp, montex, montey, montepi, sccu0, scclast, scct1, scct2, scct3; + + int64_t inmont = 0; + int64_t mcount = 0; + + double cexp = 0.0; + double montex = 0.0; + double montey = 0.0; + double montepi = 0.0; + double sccu0 = 0.0; + double scclast = 0.0; + double scct1 = 0.0; + double scct2 = 0.0; + double scct3 = 0.0; }; } // namespace detail