From 3d082ac8b28cddf87372338f328ec159c37bdf31 Mon Sep 17 00:00:00 2001 From: Michael Sumner Date: Mon, 10 Jun 2024 10:46:52 +0000 Subject: [PATCH] mode of alloc --- inst/include/gdalwarpgeneral/gdalwarpgeneral.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/inst/include/gdalwarpgeneral/gdalwarpgeneral.h b/inst/include/gdalwarpgeneral/gdalwarpgeneral.h index a84de74..bf14180 100644 --- a/inst/include/gdalwarpgeneral/gdalwarpgeneral.h +++ b/inst/include/gdalwarpgeneral/gdalwarpgeneral.h @@ -91,11 +91,12 @@ inline List gdal_warp_general(CharacterVector dsn, LogicalVector nara) { - GDALDatasetH *poSrcDS; - poSrcDS = static_cast(CPLMalloc(sizeof(GDALDatasetH) * static_cast(dsn.size()))); + GDALDatasetH *poSrcDS = nullptr;; IntegerVector sds0 = IntegerVector::create(0); for (int i = 0; i < dsn.size(); i++) { + poSrcDS = static_cast(CPLRealloc(poSrcDS, sizeof(GDALDatasetH) * static_cast(dsn.size()))); + poSrcDS[i] = gdalraster::gdalH_open_dsn(dsn[i], sds0); // unwind everything, and stop (why not unwind if all are null, message how many succeed) if (poSrcDS[i] == nullptr) {