<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p><br>
</p>
<div class="moz-cite-prefix">Le 09/01/2024 à 19:45, Fitch, Simeon
via gdal-dev a écrit :<br>
</div>
<blockquote type="cite"
cite="mid:CAAsstvEDSfbm8jPazNGvBA7+WOKbE+-_Ge+W04aS=G7tS=j=aA@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div>I have a question about the mutability of the `pahSrcDS`
argument to `GDALWarp`.</div>
<div><br>
</div>
<div>The `GDALWarp` function has the following signature:</div>
<div><br>
</div>
<div>```</div>
<div>GDALDatasetH GDALWarp(const char *pszDest, GDALDatasetH
hDstDS, int nSrcCount,<br>
GDALDatasetH *pahSrcDS,<br>
const GDALWarpAppOptions *psOptionsIn,
int *pbUsageError)<br>
</div>
<div>```</div>
<div>Source: <a
href="https://github.com/OSGeo/gdal/blob/895e9fbd63b2aa22471f4f8c69efd5ba4e700e9c/apps/gdalwarp_lib.cpp#L1379-L1381"
moz-do-not-send="true" class="moz-txt-link-freetext">https://github.com/OSGeo/gdal/blob/895e9fbd63b2aa22471f4f8c69efd5ba4e700e9c/apps/gdalwarp_lib.cpp#L1379-L1381</a><br>
</div>
<div><br>
</div>
I was curious to see that `pahSrcDS` was not `const GDALDatasetH
*pahSrcDS` or `const GDALDatasetH * const pahSrcDS`.
<div><br>
</div>
<div>What mutability and ownership conclusions should I draw
from it (if any)?
<div><br>
</div>
<div>* Might the `GDALWarp` mutate the array and/or the
pointed Datasets?</div>
</div>
</div>
</blockquote>
No. The const correctness could have indeed be done better (although
a reason for that is that in C, a "T**" is not implicitly cast as
"const T* const*", contrary to C++)<br>
<blockquote type="cite"
cite="mid:CAAsstvEDSfbm8jPazNGvBA7+WOKbE+-_Ge+W04aS=G7tS=j=aA@mail.gmail.com">
<div dir="ltr">
<div>
<div>
<div>* Is it correct to assume the caller maintains
ownership of the elements of `pahSrcDS`?</div>
</div>
</div>
</div>
</blockquote>
<p>Yes</p>
<p>Note that if the output format is VRT, then the return VRT
dataset will reference the input dataset handle (a single one is
allowed in that case). Hence, in that particular case (works also
in the general case), you should close first the output dataset
and then source dataset(s), as done by gdalwarp_bin.cpp</p>
<p>Even<br>
</p>
<span style="white-space: pre-wrap">
</span>
<pre class="moz-signature" cols="72">--
<a class="moz-txt-link-freetext" href="http://www.spatialys.com">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
</body>
</html>