*
* @return 0 on error or replaced band
*/
-int
+rt_band
rt_raster_replace_band(rt_raster raster, rt_band band, int index) {
rt_band oldband = NULL;
assert(NULL != raster);
raster->bands[index] = band;
RASTER_DEBUGF(3, "rt_raster_replace_band: new band at %p", raster->bands[index]);
- rt_band_destroy(oldband);
- return 1;
+ return oldband;
}
/**
* @param band : new band to add to raster
* @param index : index of band to replace (1-based)
*
- * @return 0 on error or 1 on success
+ * @return 0 on error or replaced band
*/
-int rt_raster_replace_band(rt_raster raster, rt_band band,
+rt_band rt_raster_replace_band(rt_raster raster, rt_band band,
int index);
/**
}
/* replace old band with new band */
- if (rt_raster_replace_band(raster, newband, nband - 1) == 0) {
+ if (rt_raster_replace_band(raster, newband, nband - 1) == NULL) {
elog(ERROR, "RASTER_reclass: Could not replace raster band of index %d with reclassified band. Returning NULL", nband);
rt_band_destroy(newband);
rt_raster_destroy(raster);
uint16_t width;
uint16_t height;
double nodata;
- int rtn;
raster = rt_raster_new(10, 10);
assert(raster); /* or we're out of virtual memory */
- rband = addBand(raster, PT_8BUI, 0, 0);
- CHECK(rband);
+ band = addBand(raster, PT_8BUI, 0, 0);
+ CHECK(band);
band = addBand(raster, PT_8BUI, 1, 255);
CHECK(band);
band = rt_band_new_inline(width, height, PT_8BUI, 1, 1, mem);
assert(band);
- rband = rt_raster_get_band(raster, 0);
- assert(rband);
-
- rtn = rt_raster_replace_band(raster, band, 0);
- CHECK(rtn);
+ rband = rt_raster_replace_band(raster, band, 0);
+ CHECK(rband);
nodata = rt_band_get_nodata(rt_raster_get_band(raster, 0));
CHECK((nodata == 1));
deepRelease(raster);
mem = rt_band_get_data(rband);
- if (mem) free(mem);
rt_band_destroy(rband);
+ if (mem) rtdealloc(mem);
}
struct rt_reclassexpr_t {
CHECK((rtn != -1));
CHECK_EQUALS(val, 255);
-
for (i = cnt - 1; i >= 0; i--) free(exprset[i]);
free(exprset);
deepRelease(raster);
for (i = 0; i < size; i++) {
/*printf("gdal_driver: %s\n", drv[i].short_name);*/
CHECK(drv[i].short_name);
+ rtdealloc(drv[i].short_name);
+ rtdealloc(drv[i].long_name);
rtdealloc(drv[i].create_options);
}