| 226 | |
| 227 | template <typename T> |
| 228 | void Realloc(T &buf, size_t size1, size_t size2, bool &success) |
| 229 | { |
| 230 | if (!success) |
| 231 | { |
| 232 | return; |
| 233 | } |
| 234 | if constexpr (sizeof(size_t) < sizeof(uint64_t)) |
| 235 | { |
| 236 | if (size1 > std::numeric_limits<size_t>::max() / size2) |
| 237 | { |
| 238 | success = false; |
| 239 | CPLError(CE_Failure, CPLE_OutOfMemory, |
| 240 | "Too big memory allocation attempt"); |
| 241 | return; |
| 242 | } |
| 243 | } |
| 244 | const auto size = size1 * size2; |
| 245 | auto oldBuf = buf.release(); |
| 246 | auto newBuf = static_cast<typename T::element_type *>( |
| 247 | VSI_REALLOC_VERBOSE(oldBuf, size)); |
| 248 | if (newBuf == nullptr) |
| 249 | { |
| 250 | VSIFree(oldBuf); |
| 251 | success = false; |
| 252 | } |
| 253 | buf.reset(newBuf); |
| 254 | } |
| 255 | |
| 256 | static void CalculateCellCenters(const GDALRasterWindow &window, |
| 257 | const GDALGeoTransform >, double *padfX, |
no test coverage detected