demand loading disabled.
- `gvpack` built with the CMake build system can now find plugins correctly at
run time. #1838
+- The ortho library now allocates trapezoid structures on-demand, removing the
+ “Trapezoid-table overflow” error that previously occurred when its upfront
+ estimation was exceeded. #56, #1880
## [7.0.2] – 2022-11-18
#endif
#define NPOINTS 4 /* only rectangles */
-#define TRSIZE(ss) (5*(ss)+1)
#define TR_FROM_UP 1 /* for traverse-direction */
#define TR_FROM_DN 2
int nsegs = 4*(ncells+1);
segment_t* segs = gv_calloc(nsegs + 1, sizeof(segment_t));
int* permute = gv_calloc(nsegs + 1, sizeof(int));
- int ntraps = TRSIZE(nsegs);
- traps_t trs = {.length = ntraps,
- .data = gv_calloc(ntraps, sizeof(trap_t))};
+
+ // First trapezoid is reserved as a sentinel. We will append later
+ // trapezoids by expanding this on-demand.
+ traps_t trs = {.length = 1, .data = gv_calloc(1, sizeof(trap_t))};
+
int nt;
if (DEBUG) {
- fprintf (stderr, "cells = %d segs = %d traps = %d\n", ncells, nsegs, ntraps);
+ fprintf (stderr, "cells = %d segs = %d traps = dynamic\n", ncells, nsegs);
}
genSegments (cells, ncells, bb, segs, 0);
if (DEBUG) {
boxes_t hor_decomp = {0};
monotonate_trapezoids(nsegs, segs, &trs, 0, &hor_decomp);
+ // reset trapezoid collection
+ free(trs.data);
+ trs = (traps_t){.length = 1, .data = gv_calloc(1, sizeof(trap_t))};
+
genSegments (cells, ncells, bb, segs, 1);
generateRandomOrdering (nsegs, permute);
nt = construct_trapezoids(nsegs, segs, permute, &trs);
qnode_t *data;
} qnodes_t;
-static int tr_idx;
-
/* Return a new node to be added into the query tree */
static int newnode(qnodes_t *qs) {
qs->data = gv_recalloc(qs->data, qs->length, qs->length + 1, sizeof(qnode_t));
/* Return a free trapezoid */
static int newtrap(traps_t *tr) {
- if (tr_idx < tr->length) {
- tr->data[tr_idx].lseg = -1;
- tr->data[tr_idx].rseg = -1;
- tr->data[tr_idx].state = ST_VALID;
- return tr_idx++;
- }
- else {
- fprintf(stderr, "newtrap: Trapezoid-table overflow %d\n", tr_idx);
- assert(0);
- return -1;
- }
+ tr->data = gv_recalloc(tr->data, tr->length, tr->length + 1, sizeof(trap_t));
+ ++tr->length;
+ return tr->length - 1;
}
/* Return the maximum of the two points into the yval structure */
// sentinel.
qnodes_t qs = {.length = 1, .data = gv_calloc(1, sizeof(qnode_t))};
- tr_idx = 1;
- memset(tr->data, 0, tr->length * sizeof(trap_t));
-
/* Add the first segment and get the query structure and trapezoid */
/* list initialised */
add_segment(permute[segi++], seg, tr, &qs);
free(qs.data);
- return tr_idx;
+ return tr->length;
}
input = Path(__file__).parent / "56.dot"
assert input.exists(), "unexpectedly missing test case"
- # FIXME: remove this block when this #56 is fixed
- if not is_ndebug_defined() and platform.system() != "Windows":
- with pytest.raises(subprocess.CalledProcessError):
- dot("svg", input)
- return
-
# process it with Graphviz
dot("svg", input)
input = Path(__file__).parent / "1880.dot"
assert input.exists(), "unexpectedly missing test case"
- # FIXME: remove this block when this #1880 is fixed
- if not is_ndebug_defined() and platform.system() != "Windows":
- with pytest.raises(subprocess.CalledProcessError):
- dot("png", input)
- return
-
# process it with Graphviz
dot("png", input)