aboutsummaryrefslogtreecommitdiff
path: root/src/lib/ndpi_analyze.c
diff options
context:
space:
mode:
authorLuca Deri <deri@ntop.org>2020-07-15 10:30:45 +0200
committerLuca Deri <deri@ntop.org>2020-07-15 10:30:45 +0200
commit9f3e3e8456f204edfc2d626b6473bb2278a1b9cb (patch)
tree504a68a1dedc607c76ef44277b74638df935ed86 /src/lib/ndpi_analyze.c
parent91d132ea3dd99e10012916f1a1ededad2e0eefab (diff)
Add ndpi_hll_reset() API call
Fixes bug in ndpi_data_window_average() with zero points
Diffstat (limited to 'src/lib/ndpi_analyze.c')
-rw-r--r--src/lib/ndpi_analyze.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/lib/ndpi_analyze.c b/src/lib/ndpi_analyze.c
index 79a3dcf59..4b4fbf72b 100644
--- a/src/lib/ndpi_analyze.c
+++ b/src/lib/ndpi_analyze.c
@@ -144,6 +144,9 @@ float ndpi_data_window_average(struct ndpi_analyze_struct *s) {
float sum = 0.0;
u_int16_t i, n = ndpi_min(s->num_data_entries, s->num_values_array_len);
+ if(n == 0)
+ return(0);
+
for(i=0; i<n; i++)
sum += s->values[i];
@@ -228,6 +231,10 @@ void ndpi_hll_destroy(struct ndpi_hll *hll) {
hll_destroy(hll);
}
+void ndpi_hll_reset(struct ndpi_hll *hll) {
+ hll_reset(hll);
+}
+
void ndpi_hll_add(struct ndpi_hll *hll, const char *data, size_t data_len) {
hll_add(hll, (const void *)data, data_len);
}