[prev in list] [next in list] [prev in thread] [next in thread] 

List:       vtkusers
Subject:    Re: [vtkusers] Double error check in vtkImageData?
From:       Elvis Stansvik <elvis.stansvik () orexplore ! com>
Date:       2017-08-31 7:00:13
Message-ID: CAE-7VJk9LNDq5mYiC8k2NJ+rYtZv3mZepTQk+u0A2Y9h4osE3A () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


I wouldn't call it a mistake, just regular defensive programming. Neither
function is documented as doing any bounds checking, so I would say that
the author of GetScalarPointer was right in checking the args, if the
intention was for that function to provide checking as an undocumented
perk, as the checking done by GetArrayPointer is not part of its contract.

Whether it should be changed for performance reasons I'll leave to the
heavyweights on this list :)

Elvis


Den 31 aug. 2017 6:54 fm skrev "Andaharoo" <Andx_roo@live.com>:

In vtkImageData, GetScalarPointer(x, y, z) error checks by checking if the
coordinates are in the bounds of the image. It then calls
GetArrayPointer(int[]) which error checks again (with identical code) which
finally returns the results.

What's the reason for this? Is this a mistake? Seems to me the first error
check is not needed.



--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/
opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at:
http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers

[Attachment #5 (text/html)]

<div dir="auto"><div>I wouldn&#39;t call it a mistake, just regular defensive \
programming. Neither function is documented as doing any bounds checking, so I would \
say that the author of GetScalarPointer was right in checking the args, if the \
intention was for that function to provide checking as an undocumented perk, as the \
checking done by GetArrayPointer is not part of its contract.</div><div \
dir="auto"><br></div><div dir="auto">Whether it should be changed for performance \
reasons I&#39;ll leave to the heavyweights on this list :)</div><div \
dir="auto"><br></div><div dir="auto">Elvis</div><div dir="auto"><br><div \
class="gmail_extra" dir="auto"><br><div class="gmail_quote">Den 31 aug. 2017 6:54 fm \
skrev &quot;Andaharoo&quot; &lt;<a \
href="mailto:Andx_roo@live.com">Andx_roo@live.com</a>&gt;:<br \
type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px \
#ccc solid;padding-left:1ex">In vtkImageData, GetScalarPointer(x, y, z) error checks \
by checking if the<br> coordinates are in the bounds of the image. It then calls<br>
GetArrayPointer(int[]) which error checks again (with identical code) which<br>
finally returns the results.<br>
<br>
What&#39;s the reason for this? Is this a mistake? Seems to me the first error<br>
check is not needed.<br>
<br>
<br>
<br>
--<br>
Sent from: <a href="http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html" \
rel="noreferrer" target="_blank">http://vtk.1045678.n5.nabble.<wbr>com/VTK-Users-f1224199.html</a><br>
 ______________________________<wbr>_________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" \
target="_blank">www.kitware.com</a><br> <br>
Visit other Kitware open-source projects at <a \
href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" \
target="_blank">http://www.kitware.com/<wbr>opensource/opensource.html</a><br> <br>
Please keep messages on-topic and check the VTK FAQ at: <a \
href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" \
target="_blank">http://www.vtk.org/Wiki/VTK_<wbr>FAQ</a><br> <br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" \
rel="noreferrer" target="_blank">http://markmail.org/search/?q=<wbr>vtkusers</a><br> \
<br> Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" \
target="_blank">http://public.kitware.com/<wbr>mailman/listinfo/vtkusers</a><br> \
</blockquote></div><br></div></div></div>



_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic