]> granicus.if.org Git - postgis/commitdiff
Postgres 12 disallows variable length arrays in C
authorDarafei Praliaskouski <me@komzpa.net>
Thu, 13 Sep 2018 14:57:39 +0000 (14:57 +0000)
committerDarafei Praliaskouski <me@komzpa.net>
Thu, 13 Sep 2018 14:57:39 +0000 (14:57 +0000)
Patch by Laurenz Albe

Closes #4177

git-svn-id: http://svn.osgeo.org/postgis/branches/2.5@16778 b70326c6-7e19-0410-871a-916f4a2858ee

NEWS
postgis/gserialized_estimate.c

diff --git a/NEWS b/NEWS
index f0538681c383d3d3d1e0eaf4884d5e8c568a00ea..fcd3d6531833dde7c80e9dc96081dfa2fc41280d 100644 (file)
--- 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
index c27755742d611874f5f49d9490c7c19aa387eb12..039070999a0708a2d30d0497076fc731295d10f8 100644 (file)
@@ -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);