From: Darafei Praliaskouski Date: Thu, 13 Sep 2018 14:57:39 +0000 (+0000) Subject: Postgres 12 disallows variable length arrays in C X-Git-Tag: 2.5.0rc2~14 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3f7420a394faa118c829be1cdb52d4620f589884;p=postgis Postgres 12 disallows variable length arrays in C Patch by Laurenz Albe Closes #4177 git-svn-id: http://svn.osgeo.org/postgis/branches/2.5@16778 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/NEWS b/NEWS index f0538681c..fcd3d6531 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,7 @@ New since PostGIS 2.5.0rc1 - #4172, Fix memory leak in lwgeom_offsetcurve (Raúl Marín) - #4164, Parse error on incorrectly nested GeoJSON input (Paul Ramsey) - #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 diff --git a/postgis/gserialized_estimate.c b/postgis/gserialized_estimate.c index c27755742..039070999 100644 --- a/postgis/gserialized_estimate.c +++ b/postgis/gserialized_estimate.c @@ -741,6 +741,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 @@ -760,10 +762,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 @@ -776,7 +776,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]; @@ -810,8 +810,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); @@ -824,11 +824,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);