[postgis-tickets] r16645 - Fix raster notices.
Darafei
komzpa at gmail.com
Sat Jul 14 03:00:34 PDT 2018
Author: komzpa
Date: 2018-07-14 15:00:33 -0700 (Sat, 14 Jul 2018)
New Revision: 16645
Modified:
trunk/raster/rt_core/rt_mapalgebra.c
trunk/raster/rt_core/rt_raster.c
trunk/raster/rt_core/rt_spatial_relationship.c
trunk/raster/rt_pg/rtpg_create.c
trunk/raster/rt_pg/rtpg_gdal.c
trunk/raster/rt_pg/rtpg_geometry.c
trunk/raster/rt_pg/rtpg_mapalgebra.c
trunk/raster/rt_pg/rtpg_statistics.c
trunk/raster/test/cunit/cu_mapalgebra.c
Log:
Fix raster notices.
References #3994
Closes https://github.com/postgis/postgis/pull/271
Modified: trunk/raster/rt_core/rt_mapalgebra.c
===================================================================
--- trunk/raster/rt_core/rt_mapalgebra.c 2018-07-13 23:30:57 UTC (rev 16644)
+++ trunk/raster/rt_core/rt_mapalgebra.c 2018-07-14 22:00:33 UTC (rev 16645)
@@ -1015,7 +1015,7 @@
for (i = 0; i < itrcount; i++) {
if (!_param->isempty[i]) {
- memcpy(rtnrast, _param->raster[i], sizeof(struct rt_raster_serialized_t));
+ memcpy(rtnrast, _param->raster[i], sizeof(struct rt_raster_t));
break;
}
}
@@ -1118,11 +1118,11 @@
switch (extenttype) {
case ET_CUSTOM:
- memcpy(rtnrast, customextent, sizeof(struct rt_raster_serialized_t));
+ memcpy(rtnrast, customextent, sizeof(struct rt_raster_t));
break;
/* first, second, last */
default:
- memcpy(rtnrast, _param->raster[i], sizeof(struct rt_raster_serialized_t));
+ memcpy(rtnrast, _param->raster[i], sizeof(struct rt_raster_t));
break;
}
rtnrast->numBands = 0;
Modified: trunk/raster/rt_core/rt_raster.c
===================================================================
--- trunk/raster/rt_core/rt_raster.c 2018-07-13 23:30:57 UTC (rev 16644)
+++ trunk/raster/rt_core/rt_raster.c 2018-07-14 22:00:33 UTC (rev 16645)
@@ -1262,11 +1262,11 @@
return NULL;
}
- if (covers)
- break;
-
- raster->width++;
- raster->height++;
+ if (!covers)
+ {
+ raster->width++;
+ raster->height++;
+ }
}
while (!covers);
@@ -1309,17 +1309,13 @@
rt_raster_destroy(raster);
return NULL;
}
+ } while (covers);
- if (!covers) {
- if (i < 1)
- raster->width++;
- else
- raster->height++;
+ if (i < 1)
+ raster->width++;
+ else
+ raster->height++;
- break;
- }
- }
- while (covers);
}
GEOSGeom_destroy(ngeom);
@@ -1336,7 +1332,7 @@
*/
int
rt_raster_is_empty(rt_raster raster) {
- return (NULL == raster || raster->height <= 0 || raster->width <= 0);
+ return (!raster || raster->height == 0 || raster->width == 0);
}
/**
@@ -2783,7 +2779,7 @@
/* check alignment flag: grid_xw */
if (
(NULL == ul_xw && NULL == ul_yw) &&
- (NULL != grid_xw && NULL != grid_xw) &&
+ (NULL != grid_xw && NULL != grid_yw) &&
FLT_NEQ(*grid_xw, extent.MinX)
) {
/* do nothing */
@@ -2798,7 +2794,7 @@
/* check alignment flag: grid_yw */
if (
(NULL == ul_xw && NULL == ul_yw) &&
- (NULL != grid_xw && NULL != grid_xw) &&
+ (NULL != grid_xw && NULL != grid_yw) &&
FLT_NEQ(*grid_yw, extent.MaxY)
) {
/* do nothing */
@@ -2815,7 +2811,7 @@
/* check alignment flag: grid_xw */
if (
(NULL == ul_xw && NULL == ul_yw) &&
- (NULL != grid_xw && NULL != grid_xw) &&
+ (NULL != grid_xw && NULL != grid_yw) &&
FLT_NEQ(*grid_xw, extent.MinX)
) {
/* do nothing */
@@ -2831,7 +2827,7 @@
/* check alignment flag: grid_yw */
if (
(NULL == ul_xw && NULL == ul_yw) &&
- (NULL != grid_xw && NULL != grid_xw) &&
+ (NULL != grid_xw && NULL != grid_yw) &&
FLT_NEQ(*grid_yw, extent.MaxY)
) {
/* do nothing */
Modified: trunk/raster/rt_core/rt_spatial_relationship.c
===================================================================
--- trunk/raster/rt_core/rt_spatial_relationship.c 2018-07-13 23:30:57 UTC (rev 16644)
+++ trunk/raster/rt_core/rt_spatial_relationship.c 2018-07-14 22:00:33 UTC (rev 16645)
@@ -995,7 +995,6 @@
int *intersects
) {
int i;
- int j;
int within = 0;
LWGEOM *hull[2] = {NULL};
@@ -1069,28 +1068,29 @@
initGEOS(rtinfo, lwgeom_geos_error);
rtn = 1;
- for (i = 0; i < 2; i++) {
- if ((rt_raster_get_convex_hull(i < 1 ? rast1 : rast2, &(hull[i])) != ES_NONE) || NULL == hull[i]) {
- for (j = 0; j < i; j++) {
- GEOSGeom_destroy(ghull[j]);
- lwgeom_free(hull[j]);
- }
- rtn = 0;
- break;
- }
- ghull[i] = (GEOSGeometry *) LWGEOM2GEOS(hull[i], 0);
- if (NULL == ghull[i]) {
- for (j = 0; j < i; j++) {
- GEOSGeom_destroy(ghull[j]);
- lwgeom_free(hull[j]);
- }
- lwgeom_free(hull[i]);
- rtn = 0;
- break;
- }
+
+ if ((rt_raster_get_convex_hull(rast1, &(hull[0])) != ES_NONE) || !hull[0]) {
+ break;
}
- if (!rtn) break;
+ ghull[0] = (GEOSGeometry *) LWGEOM2GEOS(hull[0], 0);
+ if (!ghull[0]) {
+ lwgeom_free(hull[0]);
+ break;
+ }
+ if ((rt_raster_get_convex_hull(rast2, &(hull[1])) != ES_NONE) || !hull[1]) {
+ GEOSGeom_destroy(ghull[0]);
+ lwgeom_free(hull[0]);
+ break;
+ }
+ ghull[1] = (GEOSGeometry *) LWGEOM2GEOS(hull[1], 0);
+ if (!ghull[0]) {
+ GEOSGeom_destroy(ghull[0]);
+ lwgeom_free(hull[1]);
+ lwgeom_free(hull[0]);
+ break;
+ }
+
/* test to see if raster within the other */
within = 0;
if (GEOSWithin(ghull[0], ghull[1]) == 1)
Modified: trunk/raster/rt_pg/rtpg_create.c
===================================================================
--- trunk/raster/rt_pg/rtpg_create.c 2018-07-13 23:30:57 UTC (rev 16644)
+++ trunk/raster/rt_pg/rtpg_create.c 2018-07-14 22:00:33 UTC (rev 16645)
@@ -1312,7 +1312,7 @@
int nband = arg2->nbands[i] + 1;
rt_raster_destroy(tile);
rt_raster_destroy(arg2->raster.raster);
- if (arg2->numbands) pfree(arg2->nbands);
+ pfree(arg2->nbands);
pfree(arg2);
elog(ERROR, "RASTER_tile: Could not get band %d from source raster", nband);
SRF_RETURN_DONE(funcctx);
@@ -1343,7 +1343,7 @@
if (band == NULL) {
rt_raster_destroy(tile);
rt_raster_destroy(arg2->raster.raster);
- if (arg2->numbands) pfree(arg2->nbands);
+ pfree(arg2->nbands);
pfree(arg2);
elog(ERROR, "RASTER_tile: Could not get newly added band from output tile");
SRF_RETURN_DONE(funcctx);
@@ -1368,7 +1368,7 @@
if (rt_band_get_pixel_line(_band, rx, k, len, &vals, &nvals) != ES_NONE) {
rt_raster_destroy(tile);
rt_raster_destroy(arg2->raster.raster);
- if (arg2->numbands) pfree(arg2->nbands);
+ pfree(arg2->nbands);
pfree(arg2);
elog(ERROR, "RASTER_tile: Could not get pixel line from source raster");
SRF_RETURN_DONE(funcctx);
@@ -1377,7 +1377,7 @@
if (nvals && rt_band_set_pixel_line(band, 0, j, vals, nvals) != ES_NONE) {
rt_raster_destroy(tile);
rt_raster_destroy(arg2->raster.raster);
- if (arg2->numbands) pfree(arg2->nbands);
+ pfree(arg2->nbands);
pfree(arg2);
elog(ERROR, "RASTER_tile: Could not set pixel line of output tile");
SRF_RETURN_DONE(funcctx);
@@ -1399,7 +1399,7 @@
if (band == NULL) {
rt_raster_destroy(tile);
rt_raster_destroy(arg2->raster.raster);
- if (arg2->numbands) pfree(arg2->nbands);
+ pfree(arg2->nbands);
pfree(arg2);
elog(ERROR, "RASTER_tile: Could not create new offline band for output tile");
SRF_RETURN_DONE(funcctx);
@@ -1409,7 +1409,7 @@
rt_band_destroy(band);
rt_raster_destroy(tile);
rt_raster_destroy(arg2->raster.raster);
- if (arg2->numbands) pfree(arg2->nbands);
+ pfree(arg2->nbands);
pfree(arg2);
elog(ERROR, "RASTER_tile: Could not add new offline band to output tile");
SRF_RETURN_DONE(funcctx);
@@ -1482,9 +1482,7 @@
elog(NOTICE, "Band number(s) not provided. Returning original raster");
skip = TRUE;
}
- do {
- if (skip) break;
-
+ if (!skip) {
numBands = rt_raster_get_num_bands(raster);
array = PG_GETARG_ARRAYTYPE_P(1);
@@ -1521,7 +1519,7 @@
POSTGIS_RT_DEBUGF(3, "band idx (before): %d", idx);
if (idx > numBands || idx < 1) {
- elog(NOTICE, "Invalid band index (must use 1-based). Returning original raster");
+ elog(NOTICE, "Invalid band index (must use 1-based). Returning original raster");
skip = TRUE;
break;
}
@@ -1536,7 +1534,6 @@
skip = TRUE;
}
}
- while (0);
if (!skip) {
rast = rt_raster_from_band(raster, bandNums, j);
Modified: trunk/raster/rt_pg/rtpg_gdal.c
===================================================================
--- trunk/raster/rt_pg/rtpg_gdal.c 2018-07-13 23:30:57 UTC (rev 16644)
+++ trunk/raster/rt_pg/rtpg_gdal.c 2018-07-14 22:00:33 UTC (rev 16645)
@@ -250,7 +250,7 @@
if (strlen(option)) {
options[j] = (char *) palloc(sizeof(char) * (strlen(option) + 1));
- options[j] = option;
+ strcpy(options[j], option);
j++;
}
}
@@ -323,15 +323,8 @@
SET_VARSIZE(result, result_size);
memcpy(VARDATA(result), gdal, VARSIZE(result) - VARHDRSZ);
- /* for test output
- FILE *fh = NULL;
- fh = fopen("/tmp/out.dat", "w");
- fwrite(gdal, sizeof(uint8_t), gdal_size, fh);
- fclose(fh);
- */
-
/* free gdal mem buffer */
- if (gdal) CPLFree(gdal);
+ CPLFree(gdal);
POSTGIS_RT_DEBUG(3, "RASTER_asGDALRaster: Returning pointer to GDAL raster");
PG_RETURN_POINTER(result);
@@ -649,7 +642,7 @@
dst_srs = rtpg_getSR(dst_srid);
if (NULL == dst_srs) {
- if (!no_srid) pfree(src_srs);
+ pfree(src_srs);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
elog(ERROR, "RASTER_GDALWarp: Target SRID (%d) is unknown", dst_srid);
Modified: trunk/raster/rt_pg/rtpg_geometry.c
===================================================================
--- trunk/raster/rt_pg/rtpg_geometry.c 2018-07-13 23:30:57 UTC (rev 16644)
+++ trunk/raster/rt_pg/rtpg_geometry.c 2018-07-14 22:00:33 UTC (rev 16645)
@@ -1199,7 +1199,7 @@
/* all touched */
if (!PG_ARGISNULL(14) && PG_GETARG_BOOL(14) == TRUE) {
- if (options_len < 1) {
+ if (options_len == 0) {
options_len = 1;
options = (char **) palloc(sizeof(char *) * options_len);
}
@@ -1209,7 +1209,7 @@
}
options[options_len - 1] = palloc(sizeof(char*) * (strlen("ALL_TOUCHED=TRUE") + 1));
- options[options_len - 1] = "ALL_TOUCHED=TRUE";
+ strcpy(options[options_len - 1], "ALL_TOUCHED=TRUE");
}
if (options_len) {
Modified: trunk/raster/rt_pg/rtpg_mapalgebra.c
===================================================================
--- trunk/raster/rt_pg/rtpg_mapalgebra.c 2018-07-13 23:30:57 UTC (rev 16644)
+++ trunk/raster/rt_pg/rtpg_mapalgebra.c 2018-07-14 22:00:33 UTC (rev 16645)
@@ -1050,7 +1050,7 @@
rtpg_nmapalgebraexpr_callback_arg *callback = (rtpg_nmapalgebraexpr_callback_arg *) userarg;
SPIPlanPtr plan = NULL;
int i = 0;
- int id = -1;
+ uint8_t id = 0;
if (arg == NULL)
return 0;
@@ -4715,8 +4715,7 @@
POSTGIS_RT_DEBUGF(4, "RASTER_mapAlgebraExpr: New raster now has %d bands",
rt_raster_get_num_bands(newrast));
- if (initexpr)
- pfree(initexpr);
+ pfree(initexpr);
rt_raster_destroy(raster);
PG_FREE_IF_COPY(pgraster, 0);
@@ -7004,13 +7003,13 @@
else if (spi_plan[i] != NULL) {
POSTGIS_RT_DEBUGF(4, "Using prepared plan: %d", i);
+ /* reset values to (Datum) NULL */
+ memset(values, (Datum) NULL, sizeof(Datum) * argkwcount);
+ /* reset nulls to FALSE */
+ memset(nulls, FALSE, sizeof(char) * argkwcount);
+
/* expression has argument(s) */
if (spi_argcount[i]) {
- /* reset values to (Datum) NULL */
- memset(values, (Datum) NULL, sizeof(Datum) * argkwcount);
- /* reset nulls to FALSE */
- memset(nulls, FALSE, sizeof(char) * argkwcount);
-
/* set values and nulls */
for (j = 0; j < argkwcount; j++) {
idx = argpos[i][j];
Modified: trunk/raster/rt_pg/rtpg_statistics.c
===================================================================
--- trunk/raster/rt_pg/rtpg_statistics.c 2018-07-13 23:30:57 UTC (rev 16644)
+++ trunk/raster/rt_pg/rtpg_statistics.c 2018-07-14 22:00:33 UTC (rev 16645)
@@ -309,13 +309,11 @@
SPI_cursor_fetch(portal, TRUE, 1);
while (SPI_processed == 1 && SPI_tuptable != NULL) {
tupdesc = SPI_tuptable->tupdesc;
- tuptable = SPI_tuptable;
- tuple = tuptable->vals[0];
+ tuple = SPI_tuptable->vals[0];
datum = SPI_getbinval(tuple, tupdesc, 1, &isNull);
if (SPI_result == SPI_ERROR_NOATTRIBUTE) {
-
- if (SPI_tuptable) SPI_freetuptable(tuptable);
+ SPI_freetuptable(SPI_tuptable);
SPI_cursor_close(portal);
SPI_finish();
@@ -332,8 +330,7 @@
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
-
- if (SPI_tuptable) SPI_freetuptable(tuptable);
+ SPI_freetuptable(SPI_tuptable);
SPI_cursor_close(portal);
SPI_finish();
@@ -349,7 +346,7 @@
rt_raster_destroy(raster);
- if (SPI_tuptable) SPI_freetuptable(tuptable);
+ SPI_freetuptable(SPI_tuptable);
SPI_cursor_close(portal);
SPI_finish();
@@ -364,7 +361,7 @@
rt_raster_destroy(raster);
- if (SPI_tuptable) SPI_freetuptable(tuptable);
+ SPI_freetuptable(SPI_tuptable);
SPI_cursor_close(portal);
SPI_finish();
@@ -381,7 +378,7 @@
if (NULL == stats) {
elog(NOTICE, "Cannot compute summary statistics for band at index %d. Returning NULL", bandindex);
- if (SPI_tuptable) SPI_freetuptable(tuptable);
+ SPI_freetuptable(SPI_tuptable);
SPI_cursor_close(portal);
SPI_finish();
@@ -394,8 +391,7 @@
if (NULL == rtn) {
rtn = (rt_bandstats) SPI_palloc(sizeof(struct rt_bandstats_t));
if (NULL == rtn) {
-
- if (SPI_tuptable) SPI_freetuptable(tuptable);
+ SPI_freetuptable(SPI_tuptable);
SPI_cursor_close(portal);
SPI_finish();
@@ -431,7 +427,7 @@
SPI_cursor_fetch(portal, TRUE, 1);
}
- if (SPI_tuptable) SPI_freetuptable(tuptable);
+ if (SPI_tuptable) SPI_freetuptable(SPI_tuptable);
SPI_cursor_close(portal);
SPI_finish();
@@ -1229,7 +1225,6 @@
double max = 0;
int spi_result;
Portal portal;
- SPITupleTable *tuptable = NULL;
HeapTuple tuple;
Datum datum;
bool isNull = FALSE;
@@ -1391,7 +1386,7 @@
sql = (char *) palloc(len);
if (NULL == sql) {
- if (SPI_tuptable) SPI_freetuptable(tuptable);
+ if (SPI_tuptable) SPI_freetuptable(SPI_tuptable);
SPI_finish();
if (bin_width_count) pfree(bin_width);
@@ -1408,7 +1403,7 @@
pfree(sql);
if (spi_result != SPI_OK_SELECT || SPI_tuptable == NULL || SPI_processed != 1) {
- if (SPI_tuptable) SPI_freetuptable(tuptable);
+ if (SPI_tuptable) SPI_freetuptable(SPI_tuptable);
SPI_finish();
if (bin_width_count) pfree(bin_width);
@@ -1419,13 +1414,12 @@
}
tupdesc = SPI_tuptable->tupdesc;
- tuptable = SPI_tuptable;
- tuple = tuptable->vals[0];
+ tuple = SPI_tuptable->vals[0];
tmp = SPI_getvalue(tuple, tupdesc, 1);
if (NULL == tmp || !strlen(tmp)) {
- if (SPI_tuptable) SPI_freetuptable(tuptable);
+ SPI_freetuptable(SPI_tuptable);
SPI_finish();
if (bin_width_count) pfree(bin_width);
@@ -1441,7 +1435,7 @@
tmp = SPI_getvalue(tuple, tupdesc, 2);
if (NULL == tmp || !strlen(tmp)) {
- if (SPI_tuptable) SPI_freetuptable(tuptable);
+ if (SPI_tuptable) SPI_freetuptable(SPI_tuptable);
SPI_finish();
if (bin_width_count) pfree(bin_width);
@@ -1460,7 +1454,7 @@
sql = (char *) palloc(len);
if (NULL == sql) {
- if (SPI_tuptable) SPI_freetuptable(tuptable);
+ if (SPI_tuptable) SPI_freetuptable(SPI_tuptable);
SPI_finish();
if (bin_width_count) pfree(bin_width);
@@ -1486,13 +1480,11 @@
SPI_cursor_fetch(portal, TRUE, 1);
while (SPI_processed == 1 && SPI_tuptable != NULL) {
tupdesc = SPI_tuptable->tupdesc;
- tuptable = SPI_tuptable;
- tuple = tuptable->vals[0];
+ tuple = SPI_tuptable->vals[0];
datum = SPI_getbinval(tuple, tupdesc, 1, &isNull);
if (SPI_result == SPI_ERROR_NOATTRIBUTE) {
-
- if (SPI_tuptable) SPI_freetuptable(tuptable);
+ SPI_freetuptable(SPI_tuptable);
SPI_cursor_close(portal);
SPI_finish();
@@ -1513,7 +1505,7 @@
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
- if (SPI_tuptable) SPI_freetuptable(tuptable);
+ if (SPI_tuptable) SPI_freetuptable(SPI_tuptable);
SPI_cursor_close(portal);
SPI_finish();
@@ -1532,7 +1524,7 @@
rt_raster_destroy(raster);
- if (SPI_tuptable) SPI_freetuptable(tuptable);
+ if (SPI_tuptable) SPI_freetuptable(SPI_tuptable);
SPI_cursor_close(portal);
SPI_finish();
@@ -1550,7 +1542,7 @@
rt_raster_destroy(raster);
- if (SPI_tuptable) SPI_freetuptable(tuptable);
+ if (SPI_tuptable) SPI_freetuptable(SPI_tuptable);
SPI_cursor_close(portal);
SPI_finish();
@@ -1570,7 +1562,7 @@
if (NULL == stats) {
elog(NOTICE, "Cannot compute summary statistics for band at index %d. Returning NULL", bandindex);
- if (SPI_tuptable) SPI_freetuptable(tuptable);
+ if (SPI_tuptable) SPI_freetuptable(SPI_tuptable);
SPI_cursor_close(portal);
SPI_finish();
@@ -1588,7 +1580,7 @@
if (NULL == hist || !count) {
elog(NOTICE, "Cannot compute histogram for band at index %d", bandindex);
- if (SPI_tuptable) SPI_freetuptable(tuptable);
+ if (SPI_tuptable) SPI_freetuptable(SPI_tuptable);
SPI_cursor_close(portal);
SPI_finish();
@@ -1607,7 +1599,7 @@
if (NULL == covhist) {
pfree(hist);
- if (SPI_tuptable) SPI_freetuptable(tuptable);
+ if (SPI_tuptable) SPI_freetuptable(SPI_tuptable);
SPI_cursor_close(portal);
SPI_finish();
@@ -1643,7 +1635,7 @@
SPI_cursor_fetch(portal, TRUE, 1);
}
- if (SPI_tuptable) SPI_freetuptable(tuptable);
+ if (SPI_tuptable) SPI_freetuptable(SPI_tuptable);
SPI_cursor_close(portal);
SPI_finish();
@@ -2228,13 +2220,11 @@
if (NULL != covquant) pfree(covquant);
tupdesc = SPI_tuptable->tupdesc;
- tuptable = SPI_tuptable;
- tuple = tuptable->vals[0];
+ tuple = SPI_tuptable->vals[0];
datum = SPI_getbinval(tuple, tupdesc, 1, &isNull);
if (SPI_result == SPI_ERROR_NOATTRIBUTE) {
-
- if (SPI_tuptable) SPI_freetuptable(tuptable);
+ SPI_freetuptable(SPI_tuptable);
SPI_cursor_close(portal);
SPI_finish();
@@ -2252,7 +2242,7 @@
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
- if (SPI_tuptable) SPI_freetuptable(tuptable);
+ SPI_freetuptable(SPI_tuptable);
SPI_cursor_close(portal);
SPI_finish();
@@ -2268,7 +2258,7 @@
rt_raster_destroy(raster);
- if (SPI_tuptable) SPI_freetuptable(tuptable);
+ SPI_freetuptable(SPI_tuptable);
SPI_cursor_close(portal);
SPI_finish();
@@ -2283,7 +2273,7 @@
rt_raster_destroy(raster);
- if (SPI_tuptable) SPI_freetuptable(tuptable);
+ SPI_freetuptable(SPI_tuptable);
SPI_cursor_close(portal);
SPI_finish();
@@ -2302,10 +2292,10 @@
rt_band_destroy(band);
rt_raster_destroy(raster);
- if (NULL == covquant || !count) {
+ if (!covquant || !count) {
elog(NOTICE, "Cannot compute quantiles for band at index %d", bandindex);
- if (SPI_tuptable) SPI_freetuptable(tuptable);
+ SPI_freetuptable(SPI_tuptable);
SPI_cursor_close(portal);
SPI_finish();
@@ -2325,10 +2315,10 @@
covquant2[i].value = covquant[i].value;
}
- if (NULL != covquant) pfree(covquant);
+ pfree(covquant);
quantile_llist_destroy(&qlls, qlls_count);
- if (SPI_tuptable) SPI_freetuptable(tuptable);
+ if (SPI_tuptable) SPI_freetuptable(SPI_tuptable);
SPI_cursor_close(portal);
SPI_finish();
@@ -2646,7 +2636,6 @@
char *sql = NULL;
int spi_result;
Portal portal;
- SPITupleTable *tuptable = NULL;
HeapTuple tuple;
Datum datum;
bool isNull = FALSE;
@@ -2781,7 +2770,7 @@
sql = (char *) palloc(len);
if (NULL == sql) {
- if (SPI_tuptable) SPI_freetuptable(tuptable);
+ if (SPI_tuptable) SPI_freetuptable(SPI_tuptable);
SPI_finish();
if (search_values_count) pfree(search_values);
@@ -2807,13 +2796,12 @@
SPI_cursor_fetch(portal, TRUE, 1);
while (SPI_processed == 1 && SPI_tuptable != NULL) {
tupdesc = SPI_tuptable->tupdesc;
- tuptable = SPI_tuptable;
- tuple = tuptable->vals[0];
+ tuple = SPI_tuptable->vals[0];
datum = SPI_getbinval(tuple, tupdesc, 1, &isNull);
if (SPI_result == SPI_ERROR_NOATTRIBUTE) {
- if (SPI_tuptable) SPI_freetuptable(tuptable);
+ SPI_freetuptable(SPI_tuptable);
SPI_cursor_close(portal);
SPI_finish();
@@ -2834,7 +2822,7 @@
raster = rt_raster_deserialize(pgraster, FALSE);
if (!raster) {
- if (SPI_tuptable) SPI_freetuptable(tuptable);
+ SPI_freetuptable(SPI_tuptable);
SPI_cursor_close(portal);
SPI_finish();
@@ -2853,7 +2841,7 @@
rt_raster_destroy(raster);
- if (SPI_tuptable) SPI_freetuptable(tuptable);
+ SPI_freetuptable(SPI_tuptable);
SPI_cursor_close(portal);
SPI_finish();
@@ -2871,7 +2859,7 @@
rt_raster_destroy(raster);
- if (SPI_tuptable) SPI_freetuptable(tuptable);
+ SPI_freetuptable(SPI_tuptable);
SPI_cursor_close(portal);
SPI_finish();
@@ -2889,7 +2877,7 @@
if (NULL == vcnts || !count) {
elog(NOTICE, "Cannot count the values for band at index %d", bandindex);
- if (SPI_tuptable) SPI_freetuptable(tuptable);
+ SPI_freetuptable(SPI_tuptable);
SPI_cursor_close(portal);
SPI_finish();
@@ -2906,7 +2894,7 @@
covvcnts = (rt_valuecount) SPI_palloc(sizeof(struct rt_valuecount_t) * count);
if (NULL == covvcnts) {
- if (SPI_tuptable) SPI_freetuptable(tuptable);
+ SPI_freetuptable(SPI_tuptable);
SPI_cursor_close(portal);
SPI_finish();
@@ -2942,14 +2930,12 @@
else {
covcount++;
covvcnts = SPI_repalloc(covvcnts, sizeof(struct rt_valuecount_t) * covcount);
- if (NULL == covvcnts) {
-
- if (SPI_tuptable) SPI_freetuptable(tuptable);
+ if (!covvcnts) {
+ SPI_freetuptable(SPI_tuptable);
SPI_cursor_close(portal);
SPI_finish();
if (search_values_count) pfree(search_values);
- if (NULL != covvcnts) free(covvcnts);
MemoryContextSwitchTo(oldcontext);
elog(ERROR, "RASTER_valueCountCoverage: Cannot change allocated memory for value counts of coverage");
@@ -2971,7 +2957,7 @@
SPI_cursor_fetch(portal, TRUE, 1);
}
- if (SPI_tuptable) SPI_freetuptable(tuptable);
+ if (SPI_tuptable) SPI_freetuptable(SPI_tuptable);
SPI_cursor_close(portal);
SPI_finish();
Modified: trunk/raster/test/cunit/cu_mapalgebra.c
===================================================================
--- trunk/raster/test/cunit/cu_mapalgebra.c 2018-07-13 23:30:57 UTC (rev 16644)
+++ trunk/raster/test/cunit/cu_mapalgebra.c 2018-07-14 22:00:33 UTC (rev 16645)
@@ -240,8 +240,8 @@
}
/* 0,2 */
else if (
- arg->dst_pixel[0] == 3 &&
- arg->dst_pixel[1] == 3
+ arg->dst_pixel[0] == 0 &&
+ arg->dst_pixel[1] == 2
) {
CU_ASSERT_DOUBLE_EQUAL(arg->values[0][0][0], 16, DBL_EPSILON);
CU_ASSERT_EQUAL(arg->nodata[0][0][0], 0);
More information about the postgis-tickets
mailing list