<!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 14/02/2024 à 10:00, Laurențiu Nicola
      via gdal-dev a écrit :<br>
    </div>
    <blockquote type="cite"
cite="mid:24d5b072-6eac-42a5-8075-67f1d5c36f82@betaapp.fastmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <title></title>
      <style type="text/css">#qt p.qt-MsoNormal{margin-top:0cm;margin-right:0cm;margin-left:0cm;margin-bottom:0.0001pt;font-size:11pt;font-family:"Calibri", sans-serif;}#qt a:link{color:rgb(5, 99, 193);text-decoration-line:underline;text-decoration-style:solid;text-decoration-color:currentcolor;text-decoration-thickness:auto;}#qt a:visited{color:rgb(149, 79, 114);text-decoration-line:underline;text-decoration-style:solid;text-decoration-color:currentcolor;text-decoration-thickness:auto;}#qt p{margin-right:0cm;margin-left:0cm;font-size:12pt;font-family:"Times New Roman", serif;}p.MsoNormal,p.MsoNoSpacing{margin:0}</style>
      <div style="font-family:Arial;">Hi,<br>
      </div>
      <div style="font-family:Arial;"><br>
      </div>
      <div>On Wed, Feb 14, 2024, at 10:53, Abel Pau via gdal-dev wrote:<br>
      </div>
      <blockquote type="cite" id="qt" style="">
        <div class="qt-WordSection1">
          <div
style="border-top-width:1pt;border-top-style:solid;border-top-color:rgb(227, 227, 227);border-right-width:1pt;border-right-style:solid;border-right-color:rgb(227, 227, 227);border-bottom-width:1pt;border-bottom-style:solid;border-bottom-color:rgb(227, 227, 227);border-left-width:1pt;border-left-style:solid;border-left-color:rgb(227, 227, 227);border-image-outset:0;border-image-repeat:stretch;border-image-slice:100%;border-image-source:none;border-image-width:1;padding-top:0cm;padding-right:0cm;padding-bottom:0cm;padding-left:0cm;background-color:white;background-position-x:0%;background-position-y:0%;background-repeat:repeat;background-attachment:scroll;background-image:none;background-size:auto;background-origin:padding-box;background-clip:border-box;">
            <p
style="margin-right:0cm;margin-bottom:15pt;margin-left:0cm;background-color:white;background-position-x:0%;background-position-y:0%;background-repeat:repeat;background-attachment:scroll;background-image:none;background-size:auto;background-origin:padding-box;background-clip:border-box;border-top-width:medium;border-top-style:none;border-top-color:currentcolor;border-right-width:medium;border-right-style:none;border-right-color:currentcolor;border-bottom-width:medium;border-bottom-style:none;border-bottom-color:currentcolor;border-left-width:medium;border-left-style:none;border-left-color:currentcolor;border-image-outset:0;border-image-repeat:stretch;border-image-slice:100%;border-image-source:none;border-image-width:1;padding-top:0cm;padding-right:0cm;padding-bottom:0cm;padding-left:0cm;"><span
                style="color:rgb(13, 13, 13);"><span class="font"
                  style="font-family:"Segoe UI", sans-serif;">Hi,</span></span><br>
            </p>
            <p
style="margin-right:0cm;margin-bottom:15pt;margin-left:0cm;background-color:white;background-position-x:0%;background-position-y:0%;background-repeat:repeat;background-attachment:scroll;background-image:none;background-size:auto;background-origin:padding-box;background-clip:border-box;border-top-width:medium;border-top-style:none;border-top-color:currentcolor;border-right-width:medium;border-right-style:none;border-right-color:currentcolor;border-bottom-width:medium;border-bottom-style:none;border-bottom-color:currentcolor;border-left-width:medium;border-left-style:none;border-left-color:currentcolor;border-image-outset:0;border-image-repeat:stretch;border-image-slice:100%;border-image-source:none;border-image-width:1;padding-top:0cm;padding-right:0cm;padding-bottom:0cm;padding-left:0cm;box-sizing:border-box;font-variant-ligatures:normal;font-variant-caps:normal;text-align:start;-webkit-text-stroke-width:0px;white-space:pre-wrap;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;word-spacing:0px;"><span
            style="color:rgb(13, 13, 13);"><span class="font"
            style="font-family:"Segoe UI", sans-serif;">I am currently working on a driver and have been utilizing CPL_calloc(). However, when attempting to pass the Actions, I encounter errors such as:</span></span>
</p>
            <p
style="margin-right:0cm;margin-bottom:15pt;margin-left:0cm;background-color:white;background-position-x:0%;background-position-y:0%;background-repeat:repeat;background-attachment:scroll;background-image:none;background-size:auto;background-origin:padding-box;background-clip:border-box;border-top-width:medium;border-top-style:none;border-top-color:currentcolor;border-right-width:medium;border-right-style:none;border-right-color:currentcolor;border-bottom-width:medium;border-bottom-style:none;border-bottom-color:currentcolor;border-left-width:medium;border-left-style:none;border-left-color:currentcolor;border-image-outset:0;border-image-repeat:stretch;border-image-slice:100%;border-image-source:none;border-image-width:1;padding-top:0cm;padding-right:0cm;padding-bottom:0cm;padding-left:0cm;box-sizing:border-box;font-variant-ligatures:normal;font-variant-caps:normal;text-align:start;-webkit-text-stroke-width:0px;white-space:pre-wrap;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;word-spacing:0px;"><span
            style="color:rgb(13, 13, 13);"><span class="font"
            style="font-family:"Segoe UI", sans-serif;">warning C4244: 'function': conversion from 'MM_INTERNAL_FID' to 'size_t', possible loss of data</span></span>
</p>
            <p
style="margin-right:0cm;margin-bottom:15pt;margin-left:0cm;background-color:white;background-position-x:0%;background-position-y:0%;background-repeat:repeat;background-attachment:scroll;background-image:none;background-size:auto;background-origin:padding-box;background-clip:border-box;border-top-width:medium;border-top-style:none;border-top-color:currentcolor;border-right-width:medium;border-right-style:none;border-right-color:currentcolor;border-bottom-width:medium;border-bottom-style:none;border-bottom-color:currentcolor;border-left-width:medium;border-left-style:none;border-left-color:currentcolor;border-image-outset:0;border-image-repeat:stretch;border-image-slice:100%;border-image-source:none;border-image-width:1;padding-top:0cm;padding-right:0cm;padding-bottom:0cm;padding-left:0cm;box-sizing:border-box;font-variant-ligatures:normal;font-variant-caps:normal;text-align:start;-webkit-text-stroke-width:0px;white-space:pre-wrap;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;word-spacing:0px;"><span
            style="color:rgb(13, 13, 13);"><span class="font"
            style="font-family:"Segoe UI", sans-serif;">This issue can be addressed by casting 'MM_INTERNAL_FID' (which is a GUInt64, essentially an unsigned long long) to 'size_t' (also essentially an unsigned long long). So, utilizing a cast is not
 problematic in this context.</span></span>
</p>
          </div>
        </div>
      </blockquote>
      <div style="font-family:Arial;">The warning makes sense on 32-bit
        platforms, where that cast will be problematic.<br>
      </div>
      <div style="font-family:Arial;"><br>
      </div>
      <div style="font-family:Arial;">However, while I didn't check what
        MM_INTERNAL_FID is, it doesn't sound like something calloc()
        would take.<br>
      </div>
    </blockquote>
    Agreed: if a cast to size_t is done, a range check should be done
    first if the value might be larger than
    std::numeric_limits<size_t>::max(), which might be true on
    32-bit builds<br>
    <blockquote type="cite"
cite="mid:24d5b072-6eac-42a5-8075-67f1d5c36f82@betaapp.fastmail.com">
      <div style="font-family:Arial;"><br>
      </div>
      <blockquote type="cite" id="qt" style="">
        <div class="qt-WordSection1">
          <div
style="border-top-width:1pt;border-top-style:solid;border-top-color:rgb(227, 227, 227);border-right-width:1pt;border-right-style:solid;border-right-color:rgb(227, 227, 227);border-bottom-width:1pt;border-bottom-style:solid;border-bottom-color:rgb(227, 227, 227);border-left-width:1pt;border-left-style:solid;border-left-color:rgb(227, 227, 227);border-image-outset:0;border-image-repeat:stretch;border-image-slice:100%;border-image-source:none;border-image-width:1;padding-top:0cm;padding-right:0cm;padding-bottom:0cm;padding-left:0cm;background-color:white;background-position-x:0%;background-position-y:0%;background-repeat:repeat;background-attachment:scroll;background-image:none;background-size:auto;background-origin:padding-box;background-clip:border-box;">
            <p
style="margin-right:0cm;margin-bottom:15pt;margin-left:0cm;background-color:white;background-position-x:0%;background-position-y:0%;background-repeat:repeat;background-attachment:scroll;background-image:none;background-size:auto;background-origin:padding-box;background-clip:border-box;border-top-width:medium;border-top-style:none;border-top-color:currentcolor;border-right-width:medium;border-right-style:none;border-right-color:currentcolor;border-bottom-width:medium;border-bottom-style:none;border-bottom-color:currentcolor;border-left-width:medium;border-left-style:none;border-left-color:currentcolor;border-image-outset:0;border-image-repeat:stretch;border-image-slice:100%;border-image-source:none;border-image-width:1;padding-top:0cm;padding-right:0cm;padding-bottom:0cm;padding-left:0cm;box-sizing:border-box;font-variant-ligatures:normal;font-variant-caps:normal;text-align:start;-webkit-text-stroke-width:0px;white-space:pre-wrap;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;word-spacing:0px;"><span
            style="color:rgb(13, 13, 13);"><span class="font"
            style="font-family:"Segoe UI", sans-serif;">However, I noticed in the function description it states "used for small memory allocations," which prompts me to inquire if there is an alternative calloc function for larger memory allocations</span></span>
</p>
          </div>
        </div>
      </blockquote>
      <div style="font-family:Arial;">"Small" probably means
        "infallible" here. If you want a fallible allocation (which
        you're supposed to handle), you can use VSICalloc(), VSIMalloc()
        etc.<br>
      </div>
    </blockquote>
    Agreed<br>
    <blockquote type="cite"
cite="mid:24d5b072-6eac-42a5-8075-67f1d5c36f82@betaapp.fastmail.com">
      <div style="font-family:Arial;"><br>
      </div>
      <div style="font-family:Arial;">Laurentiu<br>
      </div>
      <div style="font-family:Arial;"><br>
      </div>
      <br>
      <fieldset class="moz-mime-attachment-header"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
gdal-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/gdal-dev">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a>
</pre>
    </blockquote>
    <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>