summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a18b317)
raw | patch | inline | side by side (parent: a18b317)
author | Florian Forster <ff@octo.it> | |
Thu, 20 Nov 2014 13:35:53 +0000 (14:35 +0100) | ||
committer | Florian Forster <ff@octo.it> | |
Thu, 20 Nov 2014 13:35:53 +0000 (14:35 +0100) |
Fixed the wrap-around case and adds support for windows larger than the
history size.
history size.
src/oping.c | patch | blob | history |
diff --git a/src/oping.c b/src/oping.c
index a74cd420a8e5567a5907d6faca5db76e4ff4067c..debe23725709b3d278210f2cbc0439dd4bdf3ceb 100644 (file)
--- a/src/oping.c
+++ b/src/oping.c
/* Determine the first index in the history we need to draw
* the graph. */
history_offset = 0;
- if (((size_t) x_max) < ctx->history_size)
+ if (((size_t) x_max) < ctx->history_size) /* window is smaller than history */
{
if (ctx->history_index > x_max)
history_offset = ctx->history_index - x_max;
else /* wrap around */
- history_offset = ctx->history_index + x_max - ctx->history_size;
+ history_offset = ctx->history_index + ctx->history_size - x_max;
+ }
+ else /* window is larger than history */
+ {
+ if (ctx->history_index != ctx->history_size) /* no longer growing. */
+ history_offset = ctx->history_index;
+ else /* start-up */
+ history_offset = 0;
}
for (x = 0; x < x_max; x++)