diff options
| author | Steven Rostedt <srostedt@redhat.com> | 2010-02-10 18:34:40 -0500 |
|---|---|---|
| committer | Steven Rostedt <rostedt@goodmis.org> | 2010-02-10 18:34:40 -0500 |
| commit | f4258f18687ea19e38eccb8c7badb451d3d2d5e2 (patch) | |
| tree | 370c8d678199087bd9f8a4f9b45374f4fb7316f0 | |
| parent | bdd0561e19389a10901240dc907a969d9f97c898 (diff) | |
trace-graph: Add plot_list to hold the plots on a hash
Add an intermediate list item for hashs to let a plot be assigned
to more that one hash.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
| -rw-r--r-- | trace-graph.h | 8 | ||||
| -rw-r--r-- | trace-plot.c | 20 |
2 files changed, 19 insertions, 9 deletions
diff --git a/trace-graph.h b/trace-graph.h index f7bc117..f8d582c 100644 --- a/trace-graph.h +++ b/trace-graph.h | |||
| @@ -81,7 +81,6 @@ struct plot_callbacks { | |||
| 81 | }; | 81 | }; |
| 82 | 82 | ||
| 83 | struct graph_plot { | 83 | struct graph_plot { |
| 84 | struct graph_plot *next; /* for hash */ | ||
| 85 | int pos; | 84 | int pos; |
| 86 | char *label; | 85 | char *label; |
| 87 | const struct plot_callbacks *cb; | 86 | const struct plot_callbacks *cb; |
| @@ -93,9 +92,14 @@ struct graph_callbacks { | |||
| 93 | graph_filter_cb *filter; | 92 | graph_filter_cb *filter; |
| 94 | }; | 93 | }; |
| 95 | 94 | ||
| 95 | struct plot_list { | ||
| 96 | struct plot_list *next; | ||
| 97 | struct graph_plot *plot; | ||
| 98 | }; | ||
| 99 | |||
| 96 | struct plot_hash { | 100 | struct plot_hash { |
| 97 | struct plot_hash *next; | 101 | struct plot_hash *next; |
| 98 | struct graph_plot *plots; | 102 | struct plot_list *plots; |
| 99 | gint val; | 103 | gint val; |
| 100 | }; | 104 | }; |
| 101 | 105 | ||
diff --git a/trace-plot.c b/trace-plot.c index 5f0ab75..37b5cfc 100644 --- a/trace-plot.c +++ b/trace-plot.c | |||
| @@ -155,8 +155,10 @@ static struct plot_hash *find_hash(struct plot_hash **array, gint val) | |||
| 155 | static void add_hash(struct plot_hash **array, struct graph_plot *plot, gint val) | 155 | static void add_hash(struct plot_hash **array, struct graph_plot *plot, gint val) |
| 156 | { | 156 | { |
| 157 | struct plot_hash *hash; | 157 | struct plot_hash *hash; |
| 158 | struct plot_list *list; | ||
| 158 | gint key; | 159 | gint key; |
| 159 | 160 | ||
| 161 | list = malloc_or_die(sizeof(*list)); | ||
| 160 | hash = find_hash(array, val); | 162 | hash = find_hash(array, val); |
| 161 | if (!hash) { | 163 | if (!hash) { |
| 162 | hash = g_new0(typeof(*hash), 1); | 164 | hash = g_new0(typeof(*hash), 1); |
| @@ -167,25 +169,29 @@ static void add_hash(struct plot_hash **array, struct graph_plot *plot, gint val | |||
| 167 | array[key] = hash; | 169 | array[key] = hash; |
| 168 | } | 170 | } |
| 169 | 171 | ||
| 170 | plot->next = hash->plots; | 172 | list->next = hash->plots; |
| 171 | hash->plots = plot; | 173 | list->plot = plot; |
| 174 | |||
| 175 | hash->plots = list; | ||
| 172 | } | 176 | } |
| 173 | 177 | ||
| 174 | static void remove_hash(struct plot_hash **array, struct graph_plot *plot, gint val) | 178 | static void remove_hash(struct plot_hash **array, struct graph_plot *plot, gint val) |
| 175 | { | 179 | { |
| 176 | struct plot_hash *hash, **phash; | 180 | struct plot_hash *hash, **phash; |
| 177 | struct graph_plot **pplot; | 181 | struct plot_list **pplot; |
| 182 | struct plot_list *list; | ||
| 178 | gint key; | 183 | gint key; |
| 179 | 184 | ||
| 180 | hash = find_hash(array, val); | 185 | hash = find_hash(array, val); |
| 181 | pplot = &hash->plots; | 186 | pplot = &hash->plots; |
| 182 | 187 | ||
| 183 | while (*pplot) { | 188 | while ((list = *pplot)) { |
| 184 | if (*pplot == plot) { | 189 | if (list->plot == plot) { |
| 185 | *pplot = plot->next; | 190 | *pplot = list->next; |
| 191 | free(list); | ||
| 186 | break; | 192 | break; |
| 187 | } | 193 | } |
| 188 | pplot = &(*pplot)->next; | 194 | pplot = &list->next; |
| 189 | } | 195 | } |
| 190 | 196 | ||
| 191 | if (hash->plots) | 197 | if (hash->plots) |
