From the Redundant Department of Redundancy...
From the Redundant Department of Redundancy...
if (_List = nil) then
begin
try
_List := TStringList.Create;
except
_List.Free;
end;
end;
Never mind the fact that the code references _List immediately afterwards without checking if _List is nil or not...
if (_List = nil) then
begin
try
_List := TStringList.Create;
except
_List.Free;
end;
end;
Never mind the fact that the code references _List immediately afterwards without checking if _List is nil or not...
Trying to trap a failed TStringList.Create is like grasping at straws. When it happens, the only sane thing to do is call Halt() and pray that no permanent data got corrupted ;-)
ReplyDeleteEither that or someone really doesn't trust the RTL code :-P
ReplyDeleteand even a _List.Free won't set _List to nil. Wasn't there a procedure doing such a thing?
ReplyDeleteEric Grange Yeah, that's pretty much the definition of a catastrofic failure in 99% of the cases.
ReplyDeletePaul Foster Seems to have some serious trust issues indeed ;)
Uwe Raabe Shhh, it shall remain nameless, for it is the anti-christ. At least that's what I've heard on the Borland/CodeGear/EMB forums...
ReplyDeleteI've lately been seeing some code like that.....
ReplyDeleteWhy _List.Free is not protected? :)
ReplyDelete_List is a local variable? or a global variable?
ReplyDeleteIf a global, ok, test it.
If not its redundant.
Use finally before ".free".
Dan Sohad It's a private class member. However the try/except is completely redundant regardless.
ReplyDeletemaybe not: if not have"free memory"? ;)
ReplyDeletehummm
now i understand...
I thought was another parts omited in this code.
It's a joke!
Sorry.
FreeAndNil(_List);
ReplyDelete(runs for cover)