From d1a4b283356d285e3a8d76e2bbc2555b7cd24f86 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Thu, 24 Nov 2022 09:31:02 -0800 Subject: [PATCH] ortho monotonate_trapezoids: allocate structures based on trapezoid count `tr->length` and `TRSIZE(nsegs)` are the same value here, so this has no immediate effect. This is a step towards moving to on-demand allocation. Gitlab: #56 --- lib/ortho/partition.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/ortho/partition.c b/lib/ortho/partition.c index 0c61fc9ba..adbc6e4ae 100644 --- a/lib/ortho/partition.c +++ b/lib/ortho/partition.c @@ -596,16 +596,15 @@ monotonate_trapezoids(int nsegs, segment_t *seg, traps_t *tr, { int i, size; int tr_start; - int tr_size = TRSIZE(nsegs); - int* visited = gv_calloc(tr_size, sizeof(int)); + int* visited = gv_calloc(tr->length, sizeof(int)); - mchain = gv_calloc(tr_size, sizeof(monchain_t)); + mchain = gv_calloc(tr->length, sizeof(monchain_t)); vert = gv_calloc(nsegs + 1, sizeof(vertexchain_t)); mon = gv_calloc(nsegs, sizeof(int)); /* First locate a trapezoid which lies inside the polygon */ /* and which is triangular */ - for (i = 0; i < TRSIZE(nsegs); i++) + for (i = 0; i < tr->length; i++) if (inside_polygon(&tr->data[i], seg)) break; tr_start = i; -- 2.40.0