In debug mode application should report all things that can be considired as errors. A reference to an invalid item in a list most likely means a logical error in your code and you should get to know about it ASAP. If you simply clamp invalid index to a valid range you will not have a chance to find the error. So I would GetItem be as follows:
Code:
function TPoints2px.GetItem(Num: Integer): PPoint2px;
begin
Assert((Num >= 0)and(Num <DataCount>= 0)and(Num < DataCount) then Result:= @Data[Num]
else Result:= nil;
end;
In case of a "risky API call" fail it may be useful to write a line to log even in release version. It will help to find and fix problems remotely by end-user requests.
Bookmarks