freePara (exdot_op* op)
{
if (op->op.kind == xd_text)
- free_textpara (op->para);
+ free_textpara (op->para, 1);
}
boxf xdotBB (Agraph_t* g)
return rv;
}
-void free_textpara(textpara_t * tl)
+/* free_textpara:
+ * Free resources related to textpara_t.
+ * tl is an array of cnt textpara_t's.
+ * It is also assumed that the text stored in the str field
+ * is all stored in one large buffer shared by all of the textpara_t,
+ * so only the first one needs to free its tlp->str.
+ */
+void free_textpara(textpara_t * tl, int cnt)
{
- if (tl) {
- if (tl->str)
- free(tl->str);
- if (tl->layout && tl->free_layout)
- tl->free_layout (tl->layout);
- free(tl);
+ int i;
+ textpara_t* tlp = tl;
+
+ if (!tl) return;
+ for (i = 0; i < cnt; i++) {
+ if ((i == 0) && tlp->str)
+ free(tlp->str);
+ if (tlp->layout && tlp->free_layout)
+ tlp->free_layout (tlp->layout);
+ tlp++;
}
+ free(tl);
}
void free_label(textlabel_t * p)
if (p->html) {
free_html_label(p->u.html, 1);
} else {
- free_textpara(p->u.txt.para);
+ free_textpara(p->u.txt.para, p->u.txt.nparas);
}
free(p);
}
extern shape_desc *find_user_shape(const char *);
extern void free_line(textpara_t *);
extern void free_label(textlabel_t *);
- extern void free_textpara(textpara_t * tl);
+ extern void free_textpara(textpara_t * tl, int);
extern void getdouble(graph_t * g, char *name, double *result);
extern splines *getsplinepoints(edge_t * e);
extern void gv_fixLocale (int set);
GD_cluster_was_collapsed(clust) = FALSE;
dot_cleanup(clust);
}
+ if (GD_clust(g)) free (GD_clust(g));
+ if (GD_rankleader(g)) free (GD_rankleader(g));
free_list(GD_comp(g));
- if ((g == agroot(g)) && GD_rank(g)) {
+ if (GD_rank(g)) {
for (i = GD_minrank(g); i <= GD_maxrank(g); i++)
- free(GD_rank(g)[i].v);
- free(GD_rank(g));
+ free(GD_rank(g)[i].av);
+ if (GD_minrank(g) == -1)
+ free(GD_rank(g)-1);
+ else
+ free(GD_rank(g));
}
if (g != agroot(g))
#ifndef WITH_CGRAPH
GD_rank(g) = rptr + 1;
for (r = GD_maxrank(g); r >= 0; r--)
GD_rank(g)[r] = GD_rank(g)[r - 1];
- GD_rank(g)[r].n = GD_rank(g)[0].an = 0;
- GD_rank(g)[r].v = GD_rank(g)[0].av = N_NEW(2, node_t *);
+ GD_rank(g)[r].n = GD_rank(g)[r].an = 0;
+ GD_rank(g)[r].v = GD_rank(g)[r].av = N_NEW(2, node_t *);
GD_rank(g)[r].flat = NULL;
GD_rank(g)[r].ht1 = GD_rank(g)[r].ht2 = 1;
GD_rank(g)[r].pht1 = GD_rank(g)[r].pht2 = 1;