Commit fa3d883d authored by Darafei Praliaskouski's avatar Darafei Praliaskouski

Postgres 12 disallows variable length arrays in C

Patch by Laurenz Albe

Closes #4177



git-svn-id: http://svn.osgeo.org/postgis/trunk@16777 b70326c6-7e19-0410-871a-916f4a2858ee
parent c61e871d
Pipeline #30117504 failed with stage
in 7 minutes and 18 seconds
......@@ -13,6 +13,7 @@ PostGIS 3.0.0
- #4172, Fix memory leak in lwgeom_offsetcurve (Raúl Marín)
- #4173, Fix undefined behaviour in ptarray_segmentize2d (Raúl Marín)
- #4176, ST_Intersects supports GEOMETRYCOLLECTION (Darafei Praliaskouski)
- #4177, Postgres 12 disallows variable length arrays in C (Laurenz Albe)
PostGIS 2.5.0rc1
2018/08/19
......
......@@ -740,6 +740,8 @@ nd_box_ratio(const ND_BOX *b1, const ND_BOX *b2, int ndims)
return ivol / vol2;
}
/* How many bins shall we use in figuring out the distribution? */
#define NUM_BINS 50
/**
* Calculate how much a set of boxes is homogenously distributed
......@@ -759,10 +761,8 @@ nd_box_ratio(const ND_BOX *b1, const ND_BOX *b2, int ndims)
static int
nd_box_array_distribution(const ND_BOX **nd_boxes, int num_boxes, const ND_BOX *extent, int ndims, double *distribution)
{
/* How many bins shall we use in figuring out the distribution? */
static int num_bins = 50;
int d, i, k, range;
int counts[num_bins];
int counts[NUM_BINS];
double smin, smax; /* Spatial min, spatial max */
double swidth; /* Spatial width of dimension */
#if POSTGIS_DEBUG_LEVEL >= 3
......@@ -775,7 +775,7 @@ nd_box_array_distribution(const ND_BOX **nd_boxes, int num_boxes, const ND_BOX *
for ( d = 0; d < ndims; d++ )
{
/* Initialize counts for this dimension */
memset(counts, 0, sizeof(int)*num_bins);
memset(counts, 0, sizeof(int)*NUM_BINS);
smin = extent->min[d];
smax = extent->max[d];
......@@ -809,8 +809,8 @@ nd_box_array_distribution(const ND_BOX **nd_boxes, int num_boxes, const ND_BOX *
}
/* What bins does this range correspond to? */
bmin = num_bins * (minoffset) / swidth;
bmax = num_bins * (maxoffset) / swidth;
bmin = NUM_BINS * (minoffset) / swidth;
bmax = NUM_BINS * (maxoffset) / swidth;
POSTGIS_DEBUGF(4, " dimension %d, feature %d: bin %d to bin %d", d, i, bmin, bmax);
......@@ -823,11 +823,11 @@ nd_box_array_distribution(const ND_BOX **nd_boxes, int num_boxes, const ND_BOX *
}
/* How dispersed is the distribution of features across bins? */
range = range_quintile(counts, num_bins);
range = range_quintile(counts, NUM_BINS);
#if POSTGIS_DEBUG_LEVEL >= 3
average = avg(counts, num_bins);
sdev = stddev(counts, num_bins);
average = avg(counts, NUM_BINS);
sdev = stddev(counts, NUM_BINS);
sdev_ratio = sdev/average;
POSTGIS_DEBUGF(3, " dimension %d: range = %d", d, range);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment