for (j = 0; j < step; j++) {
yval = acc[i + j * rrd_result->ds_count];
- if (isnan(yval)) {
+ if (isnan (yval)) {
nan_cnt++;
}
else {
struct rspamd_controller_worker_ctx *ctx;
rspamd_ftok_t srch, *value;
struct rspamd_rrd_query_result *rrd_result;
- gulong i, j, k, start_row, cnt, t, ts, step;
+ gulong i, k, start_row, cnt, t, ts, step;
gdouble *acc;
ucl_object_t *res, *elt[4];
enum {
/* Create window */
step = (rrd_result->rra_rows / desired_points + 0.5);
+ g_assert (step >= 1);
acc = g_malloc0 (sizeof (double) * rrd_result->ds_count * step);
for (i = start_row, cnt = 0; cnt < rrd_result->rra_rows;
cnt ++) {
- for (j = 0; j < rrd_result->ds_count; j++) {
- if (k < step) {
- /* Just update window */
- acc[k * rrd_result->ds_count + j] =
- rrd_result->data[i * rrd_result->ds_count + j];
- k ++;
- }
- else {
- t = ts * rrd_result->pdp_per_cdp;
- /* Need a fresh point */
- rspamd_controller_graph_point (t, step, rrd_result, acc, elt);
- k = 0;
- }
+ memcpy (&acc[k * rrd_result->ds_count],
+ &rrd_result->data[i * rrd_result->ds_count],
+ sizeof (gdouble) * rrd_result->ds_count);
+
+ if (k < step - 1) {
+ k ++;
+ }
+ else {
+ t = ts * rrd_result->pdp_per_cdp;
+
+ /* Need a fresh point */
+ rspamd_controller_graph_point (t, step, rrd_result, acc, elt);
+ k = 0;
}
if (i == rrd_result->rra_rows - 1) {