From bc610bb3ee6fa58ddd679733d1f6a7a2fb3a4764 Mon Sep 17 00:00:00 2001 From: Alfredo Cardigliano Date: Wed, 10 Sep 2025 15:45:56 +0200 Subject: [PATCH] Add comments --- src/Flow.cpp | 9 ++++++++- src/PartializableFlowTrafficStats.cpp | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Flow.cpp b/src/Flow.cpp index 442b441d83..de5af91a01 100644 --- a/src/Flow.cpp +++ b/src/Flow.cpp @@ -4872,13 +4872,20 @@ void Flow::housekeep(time_t t) { /* *************************************** */ +/** + * Returns partial traffic stats by computing a delta between current flow stats ("stats") + * and the previous snapshot ("dst"). + * Note: + * - Delta is returned in "fts" + * - "dst" is updated taking the "stats" value + */ bool Flow::get_partial_traffic_stats(PartializableFlowTrafficStats **dst, PartializableFlowTrafficStats *fts, bool *first_partial) const { if(!fts || !dst) return (false); if(!*dst) { - if(!(*dst = new (std::nothrow) PartializableFlowTrafficStats())) + if((*dst = new (std::nothrow) PartializableFlowTrafficStats()) == NULL) return (false); *first_partial = true; } else { diff --git a/src/PartializableFlowTrafficStats.cpp b/src/PartializableFlowTrafficStats.cpp index 552884aafd..8b5790a101 100644 --- a/src/PartializableFlowTrafficStats.cpp +++ b/src/PartializableFlowTrafficStats.cpp @@ -287,7 +287,7 @@ void PartializableFlowTrafficStats::incDNSResp(u_int16_t resp_code) { void PartializableFlowTrafficStats::get_partial(PartializableFlowTrafficStats *dst, PartializableFlowTrafficStats *fts) const { - /* Set temp to the current value */ + /* Set tmp to the current value */ PartializableFlowTrafficStats tmp(*this); /* Compute the differences between the snapshot tmp and the values found in