diff options
author | Luca Deri <deri@ntop.org> | 2021-02-09 12:55:11 +0100 |
---|---|---|
committer | Luca Deri <deri@ntop.org> | 2021-02-09 12:55:11 +0100 |
commit | b960809d3ed775aa37adc489a1664635aeaaba28 (patch) | |
tree | 5e381e4c05fdec791140a519d4d049804a8ea6ea /src | |
parent | 4abaf3e279b8ef6e32dad79c8ed9da56a977989d (diff) |
Minor code improvements
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/ndpi_analyze.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/lib/ndpi_analyze.c b/src/lib/ndpi_analyze.c index 38f74bc0b..d4966791e 100644 --- a/src/lib/ndpi_analyze.c +++ b/src/lib/ndpi_analyze.c @@ -843,13 +843,17 @@ int ndpi_alloc_rsi(struct ndpi_rsi_struct *s, u_int16_t num_learning_values) { } } +/* ************************************* */ + void ndpi_free_rsi(struct ndpi_rsi_struct *s) { ndpi_free(s->gains), ndpi_free(s->losses); } +/* ************************************* */ + /* This function adds a new value and returns the computed RSI, or -1 - if there are too many points (< num_learning_values) + if there are too few points (< num_learning_values) RSI < 30 (too many losses) RSI > 70 (too many gains) @@ -887,7 +891,7 @@ float ndpi_rsi_add_value(struct ndpi_rsi_struct *s, const u_int32_t value) { if(s->next_index == 0) s->rsi_ready = 1; /* We have completed one round */ if(!s->rsi_ready) - return(0); + return(-1); /* Too early */ else if(s->total_losses == 0) /* Avoid division by zero (**) */ return(100.); else { |