aboutsummaryrefslogtreecommitdiff
path: root/gcc/graphds.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/graphds.c')
-rw-r--r--gcc/graphds.c22
1 files changed, 5 insertions, 17 deletions
diff --git a/gcc/graphds.c b/gcc/graphds.c
index 3d64d89..d009c13 100644
--- a/gcc/graphds.c
+++ b/gcc/graphds.c
@@ -58,8 +58,10 @@ new_graph (int n_vertices)
{
struct graph *g = XNEW (struct graph);
+ gcc_obstack_init (&g->ob);
g->n_vertices = n_vertices;
- g->vertices = XCNEWVEC (struct vertex, n_vertices);
+ g->vertices = XOBNEWVEC (&g->ob, struct vertex, n_vertices);
+ memset (g->vertices, 0, sizeof (struct vertex) * n_vertices);
return g;
}
@@ -69,10 +71,9 @@ new_graph (int n_vertices)
struct graph_edge *
add_edge (struct graph *g, int f, int t)
{
- struct graph_edge *e = XNEW (struct graph_edge);
+ struct graph_edge *e = XOBNEW (&g->ob, struct graph_edge);
struct vertex *vf = &g->vertices[f], *vt = &g->vertices[t];
-
e->src = f;
e->dest = t;
@@ -324,20 +325,7 @@ for_each_edge (struct graph *g, graphds_edge_callback callback)
void
free_graph (struct graph *g)
{
- struct graph_edge *e, *n;
- struct vertex *v;
- int i;
-
- for (i = 0; i < g->n_vertices; i++)
- {
- v = &g->vertices[i];
- for (e = v->succ; e; e = n)
- {
- n = e->succ_next;
- free (e);
- }
- }
- free (g->vertices);
+ obstack_free (&g->ob, NULL);
free (g);
}