X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=graph.c;h=9761a1ad428b1b7015265456b9779a719105a605;hp=91ddc8937fa4ed53290742f1dc5a563266ec3b33;hb=3ca30e63c16734837336380b6f40b85e97579167;hpb=b65c7ec44355b9bc4d6c5ee6613dfb895dace3d6 diff --git a/graph.c b/graph.c index 91ddc893..9761a1ad 100644 --- a/graph.c +++ b/graph.c @@ -33,9 +33,6 @@ #include "graph.h" #include "flist.h" #include "lib/prio_tree.h" -#include "gettime.h" -struct thread_data; -#include "time.h" /* * Allowable difference to show tooltip @@ -691,6 +688,7 @@ static void graph_label_add_value(struct graph_label *i, void *value, struct graph_value *x; x = malloc(sizeof(*x)); + memset(x, 0, sizeof(*x)); x->value = value; if (tooltip) x->tooltip = strdup(tooltip); @@ -710,13 +708,13 @@ static void graph_label_add_value(struct graph_label *i, void *value, double miny = yval / TOOLTIP_DELTA; double maxy = yval * TOOLTIP_DELTA; + INIT_PRIO_TREE_NODE(&x->node); x->node.start = miny; x->node.last = maxy; if (x->node.last == x->node.start) x->node.last++; prio_tree_insert(&i->prio_tree, &x->node); - printf("insert (x=%u,y=%u) range %lu-%lu (%s)\n", (int)getx(x), (int)gety(x), x->node.start, x->node.last, x->tooltip); i->tooltip_count++; } @@ -781,13 +779,18 @@ int graph_add_xy_data(struct graph *bg, const char *label, return 0; } -static void graph_free_values(struct graph_value *values) +static void graph_free_values(struct graph_label *l, struct graph_value *values) { struct graph_value *i, *next; for (i = values; i; i = next) { next = i->next; free(i->value); + if (i->tooltip) { + free(i->tooltip); + prio_tree_remove(&l->prio_tree, &i->node); + l->tooltip_count--; + } free(i); } } @@ -798,7 +801,7 @@ static void graph_free_labels(struct graph_label *labels) for (i = labels; i; i = next) { next = i->next; - graph_free_values(i->values); + graph_free_values(i, i->values); free(i); } }