From: erg Date: Fri, 5 Feb 2010 20:07:46 +0000 (+0000) Subject: Fix bug 1873 X-Git-Tag: LAST_LIBGRAPH~32^2~1448 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b8a7861b5ef85dfb49467b13b1a3260ff2d87763;p=graphviz Fix bug 1873 --- diff --git a/lib/common/routespl.c b/lib/common/routespl.c index b41336b5f..4b006fcaa 100644 --- a/lib/common/routespl.c +++ b/lib/common/routespl.c @@ -725,6 +725,10 @@ static void mkspacep(int size) if (size > maxpn) { int newmax = maxpn + (size / PINC + 1) * PINC; ps = RALLOC(newmax, ps, pointf); + if (!ps) { + agerr(AGERR, "cannot re-allocate ps\n"); + abort(); + } maxpn = newmax; } } diff --git a/lib/dotgen/dotsplines.c b/lib/dotgen/dotsplines.c index c2e0a1c38..f73b4bfa6 100644 --- a/lib/dotgen/dotsplines.c +++ b/lib/dotgen/dotsplines.c @@ -1347,6 +1347,8 @@ makeLineEdge(edge_t* fe, pointf* points, node_t** hp) return pn; } +#define NUMPTS 2000 + /* make_regular_edge: */ static void @@ -1359,9 +1361,18 @@ make_regular_edge(spline_info_t* sp, path * P, edge_t ** edges, int ind, int cnt pathend_t tend, hend; boxf b; int boxn, sl, si, smode, i, j, dx, pn, hackflag, longedge; - pointf pointfs[1000], pointfs2[1000]; + static pointf* pointfs; + static pointf* pointfs2; + static int numpts; + static int numpts2; int pointn; + if (!pointfs) { + pointfs = N_GNEW(NUMPTS, pointf); + pointfs2 = N_GNEW(NUMPTS, pointf); + numpts = NUMPTS; + numpts2 = NUMPTS; + } sl = 0; e = edges[ind]; g = agraphof(agtail(e)); @@ -1468,6 +1479,14 @@ make_regular_edge(spline_info_t* sp, path * P, edge_t ** edges, int ind, int cnt } if (pn == 0) return; + + if (pointn + pn > numpts) { + /* This should be enough to include 3 extra points added by + * straight_path below. + */ + numpts = 2*(pointn+pn); + pointfs = RALLOC(numpts, pointfs, pointf); + } for (i = 0; i < pn; i++) { pointfs[pointn++] = ps[i]; } @@ -1511,6 +1530,10 @@ make_regular_edge(spline_info_t* sp, path * P, edge_t ** edges, int ind, int cnt } if (pn == 0) return; + if (pointn + pn > numpts) { + numpts = 2*(pointn+pn); + pointfs = RALLOC(numpts, pointfs, pointf); + } for (i = 0; i < pn; i++) { pointfs[pointn++] = ps[i]; } @@ -1527,6 +1550,11 @@ make_regular_edge(spline_info_t* sp, path * P, edge_t ** edges, int ind, int cnt dx = sp->Multisep * (cnt - 1) / 2; for (i = 1; i < pointn - 1; i++) pointfs[i].x -= dx; + + if (numpts > numpts2) { + numpts2 = numpts; + pointfs2 = RALLOC(numpts2, pointfs2, pointf); + } for (i = 0; i < pointn; i++) pointfs2[i] = pointfs[i]; clip_and_install(fe, hn, pointfs2, pointn, &sinfo);