[GRASS-SVN] r70684 - grass/branches/releasebranch_7_2/lib/calc
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Feb 26 06:11:40 PST 2017
Author: mmetz
Date: 2017-02-26 06:11:40 -0800 (Sun, 26 Feb 2017)
New Revision: 70684
Modified:
grass/branches/releasebranch_7_2/lib/calc/xnmedian.c
Log:
calclib: fix for #3296 (backport trunk r70683)
Modified: grass/branches/releasebranch_7_2/lib/calc/xnmedian.c
===================================================================
--- grass/branches/releasebranch_7_2/lib/calc/xnmedian.c 2017-02-26 14:08:40 UTC (rev 70683)
+++ grass/branches/releasebranch_7_2/lib/calc/xnmedian.c 2017-02-26 14:11:40 UTC (rev 70684)
@@ -68,8 +68,8 @@
CELL *res = args[0];
CELL **argv = (CELL **) &args[1];
CELL *a = array;
- CELL *a1 = &a[(argc - 1) / 2];
- CELL *a2 = &a[argc / 2];
+ CELL *a1;
+ CELL *a2;
for (i = 0; i < columns; i++) {
int n = 0;
@@ -82,10 +82,10 @@
if (!n)
SET_NULL_C(&res[i]);
- else if (n == 1)
- res[i] = *a1;
else {
qsort(a, n, sizeof(CELL), icmp);
+ a1 = &a[(n - 1) / 2];
+ a2 = &a[n / 2];
res[i] = (*a1 + *a2) / 2;
}
}
@@ -97,8 +97,8 @@
FCELL *res = args[0];
FCELL **argv = (FCELL **) &args[1];
FCELL *a = array;
- FCELL *a1 = &a[(argc - 1) / 2];
- FCELL *a2 = &a[argc / 2];
+ FCELL *a1;
+ FCELL *a2;
for (i = 0; i < columns; i++) {
int n = 0;
@@ -111,10 +111,10 @@
if (!n)
SET_NULL_F(&res[i]);
- else if (n == 1)
- res[i] = *a1;
else {
qsort(a, n, sizeof(FCELL), fcmp);
+ a1 = &a[(n - 1) / 2];
+ a2 = &a[n / 2];
res[i] = (*a1 + *a2) / 2;
}
}
@@ -126,8 +126,8 @@
DCELL *res = args[0];
DCELL **argv = (DCELL **) &args[1];
DCELL *a = array;
- DCELL *a1 = &a[(argc - 1) / 2];
- DCELL *a2 = &a[argc / 2];
+ DCELL *a1;
+ DCELL *a2;
for (i = 0; i < columns; i++) {
int n = 0;
@@ -140,10 +140,10 @@
if (!n)
SET_NULL_D(&res[i]);
- else if (n == 1)
- res[i] = *a1;
else {
qsort(a, n, sizeof(DCELL), dcmp);
+ a1 = &a[(n - 1) / 2];
+ a2 = &a[n / 2];
res[i] = (*a1 + *a2) / 2;
}
}
More information about the grass-commit
mailing list