+ /* Copy all values from by_time to by_value. */
+ memcpy (ctx->history_by_value, ctx->history_by_time,
+ sizeof (ctx->history_by_time));
+
+ /* Remove impossible values caused by adding a new host */
+ for (i = 0; i < ctx->history_size; i++)
+ if (ctx->history_by_value[i] < 0)
+ ctx->history_by_value[i] = NAN;
+
+ /* Sort all RTTs. */
+ qsort (ctx->history_by_value, ctx->history_size, sizeof
+ (ctx->history_by_value[0]), compare_double);
+
+ /* Update the number of received RTTs. */
+ ctx->history_received = 0;
+ for (i = 0; i < ctx->history_size; i++)
+ if (!isnan (ctx->history_by_value[i]))
+ ctx->history_received++;
+
+ /* Mark as clean. */
+ ctx->history_dirty = 0;
+} /* }}} void clean_history */
+
+static double percentile_to_latency (ping_context_t *ctx, /* {{{ */