Re: D2005 Code Folding
- From: Ivo Bauer <abuer@xxxxxx>
- Date: Thu, 11 Aug 2005 03:11:00 +0200
Kostas Terzides napsal(a):
Well, actually there is a difference. Consider, this buggy function:
Function BuildAStringList:TStringList; begin result:=TStringList.Create; result.Add('blah'); If BooleanBlah then Raise Exception.Create('Exception'); end;
and if you would call this as usual: AStringList:=BuildAStringList; try ..... finally AStringLst.Free; end;
then you'd have a memory leak. Putting a critical function before try means that we /trust/ this function to properly handle any exception after making any memory allocation (or other important stuff) that means we /expect/ it to behave like this:
Kostas, I think that this is completely different story. When you have a function that creates an instance of object, then it is reasonable to take a care of any exception that function could raise and free the newly created object. The difference here is that we are not interested in catching *any* exceptions that a call to ECS might throw (we don't need to free/release anything here at this point), but instead, after ECS was *successfully* called and therefore critical section acquired, we need to ensure that the corresponding LCS gets called so we have to protect the code between these two calls that could raise an exception.
-- Ivo Bauer Software Developer OZM Research, s.r.o.
________________________________________________
ModLink - MODBUS Messaging Components for Delphi http://www.ozm.cz/ivobauer/modlink/ ________________________________________________ .
- References:
- D2005 Code Folding
- From: Allen Drennan
- Re: D2005 Code Folding
- From: Ivo Bauer
- Re: D2005 Code Folding
- From: Allen Drennan
- Re: D2005 Code Folding
- From: Craig Stuntz [TeamB]
- Re: D2005 Code Folding
- From: Allen Drennan
- Re: D2005 Code Folding
- From: Craig Stuntz [TeamB]
- Re: D2005 Code Folding
- From: Allen Drennan
- Re: D2005 Code Folding
- From: Craig Stuntz [TeamB]
- Re: D2005 Code Folding
- From: Michael Anonymous
- Re: D2005 Code Folding
- From: Ivo Bauer
- Re: D2005 Code Folding
- From: Michael Anonymous
- Re: D2005 Code Folding
- From: Ivo Bauer
- Re: D2005 Code Folding
- From: Michael Anonymous
- Re: D2005 Code Folding
- From: Ivo Bauer
- Re: D2005 Code Folding
- From: Kostas Terzides
- D2005 Code Folding
- Prev by Date: Re: D2005 Code Folding
- Next by Date: Re: D2005 Code Folding
- Previous by thread: Re: D2005 Code Folding
- Next by thread: Re: D2005 Code Folding
- Index(es):
Relevant Pages
|