diff options
Diffstat (limited to 'trace-plot.c')
| -rw-r--r-- | trace-plot.c | 20 |
1 files changed, 13 insertions, 7 deletions
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) |
