MCPcopy Create free account
hub / github.com/OSGeo/gdal / Realloc

Function Realloc

alg/zonal.cpp:228–254  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

226
227template <typename T>
228void 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
256static void CalculateCellCenters(const GDALRasterWindow &window,
257 const GDALGeoTransform &gt, double *padfX,

Callers 4

ProcessRasterZonesFunction · 0.85
zonal.cppFile · 0.85

Calls 5

CPLErrorFunction · 0.85
VSIFreeFunction · 0.85
maxFunction · 0.50
releaseMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected