<div dir="ltr"><div dir="ltr"><div dir="ltr">On Fri, Jan 30, 2026 at 6:44 PM Even Rouault <<a href="mailto:even.rouault@spatialys.com" target="_blank">even.rouault@spatialys.com</a>> wrote:</div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><u></u>
<div>
<p>Andrew,</p>
<p>we regularly do slightly forward incompatible changes in the C++
API, and they are documented in
<a href="https://gdal.org/en/latest/user/migration_guide.html" target="_blank">https://gdal.org/en/latest/user/migration_guide.html</a> . </p>
<p>That change has the advantage of avoiding potential usage errors,
in particular erroneous use of CSLDestroy() on the return value,
which was possible when we returned "char **". That way, you can
distinguish that GetMetadata() return doesn't need to be freed,
whereas methods such as <a>GDALDataset::GetMetadataDomainList()</a> or
GetFileList() that return a "char**" do need to have their return
value CSLDestroy()'ed after use</p></div></blockquote><div>I guess my feeling is that if the interface has been good enough for 30 years than it doesn't really need to be changed. Programmers need to take responsibility to use a library properly.</div><div><br></div><div>You could leave the current interface in place and add functions to provide better safety and an interface more expected by C++ programmers. For example:</div><div><br></div><div> std::vector<std::string> Metadata(const std::string& domain = "")<br> {<br> std::vector<std::string> v;<br> char **p = GetMetadata(domain.c_str());<br> while (p)<br> v.emplace_back(*p++);<br> return v;<br> }</div><div><br> std::vector<std::string_view> MetadataView(const std::string& domain = "")<br> {<br> std::vector<std::string_view> v;<br> char **p = GetMetadata(domain.c_str());<br> while (p)<br> v.emplace_back(*p++);<br> return v;<br> }</div></div><div><br>These functions can be made const without too much trouble as well.<br><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Andrew Bell</div><a href="mailto:andrew.bell.ia@gmail.com" target="_blank">andrew.bell.ia@gmail.com</a></div></div></div>
</div>