<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, May 20, 2019 at 11:57 AM Markus Metz <<a href="mailto:markus.metz.giswork@gmail.com">markus.metz.giswork@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><br><br>On Mon, May 20, 2019 at 5:39 PM Vaclav Petras <<a href="mailto:wenzeslaus@gmail.com" target="_blank">wenzeslaus@gmail.com</a>> wrote:<br>><br>> Hi MarkusM and all,<br>><br>> I'm trying to understand if the Segment_open() [1] function fills with zeros or not. I don't think it does since it is calling G_malloc (malloc) or Segment_format_nofill(). However, it is not completely clear to me what is supposed to be doing because documentation still says it calls Segment_format() and I don't understand context of the related commit [2, 3] and the usage of lseek and USE_LSEEK are not clear to me from format.c [4].<br><div><br></div><div>Segment_open() uses Segment_format_nofill() [1], if it can not use the all-in-memory cache. The documentation has not been updated accordingly (yet).</div></div></blockquote><div><br></div><div>Thank you. Just be to be sure: Now, if you want to ensure that it is zero-filled across platform, you need to do it yourself using Segment_put(), right? (Assuming you want to use Segment_open().) The exact role of lseek() here is still unclear to me (the hole and \0 bytes). </div><div><br></div><div>Would Segment_open_zero_fill() make sense, i.e. do you know if Segment_fill() faster then Segment_put()?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div> The advantage of no fill, only lseek, is that it is faster, the disadvantage is that any "no space left on device" error will be encountered only later on, and you always need to check the return code of Segment_put().<br></div></div></blockquote><div><br></div><div>Makes sense. I'll document that as well.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div></div><div><br></div><div>HTH,</div><div><br></div><div>Markus M<br></div><div><br></div><div>[1] <a href="https://github.com/OSGeo/grass/blob/master/lib/segment/open.c#L89" target="_blank">https://github.com/OSGeo/grass/blob/master/lib/segment/open.c#L89</a></div><div><br></div><div>></div>> Markus, can you please clarify that for me? I will then update the documentation with whatever is needed.<br>><br>> Thanks,<br>> Vaclav<br>><br>> [1] <a href="https://grass.osgeo.org/programming7/segment_2open_8c.html#ae24d2e794c66c0512b67d7cea8b2ba9a" target="_blank">https://grass.osgeo.org/programming7/segment_2open_8c.html#ae24d2e794c66c0512b67d7cea8b2ba9a</a><br>> [2] <a href="https://github.com/OSGeo/grass/commit/7a0d8d749537acd6d5c4baea11dbb6167fdef916" target="_blank">https://github.com/OSGeo/grass/commit/7a0d8d749537acd6d5c4baea11dbb6167fdef916</a><br>> [3] <a href="https://trac.osgeo.org/grass/changeset/73268" target="_blank">https://trac.osgeo.org/grass/changeset/73268</a><br>> [4] <a href="https://github.com/OSGeo/grass/blob/master/lib/segment/format.c" target="_blank">https://github.com/OSGeo/grass/blob/master/lib/segment/format.c</a></div>
</blockquote></div></div>