summaryrefslogtreecommitdiff
path: root/graph.c
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2012-03-21 18:54:30 +0100
committerJens Axboe <axboe@kernel.dk>2012-03-21 18:54:30 +0100
commit3ca30e63c16734837336380b6f40b85e97579167 (patch)
tree946df1fce6587e48150c4aa82974e62e3a9f09b6 /graph.c
parent29b88e05d7bd205420995a8de8b5349950f92096 (diff)
downloadfio-3ca30e63c16734837336380b6f40b85e97579167.tar.gz
fio-3ca30e63c16734837336380b6f40b85e97579167.tar.bz2
graph: fix for unitialized graph_value nodes
And leaking tooltip/node on free. Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'graph.c')
-rw-r--r--graph.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/graph.c b/graph.c
index 7304b009..9761a1ad 100644
--- a/graph.c
+++ b/graph.c
@@ -688,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);
@@ -707,6 +708,7 @@ 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)
@@ -777,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);
}
}
@@ -794,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);
}
}