Morning all.
Yesterday day I spent a couple more wasted hours sorting out a problemo in
my software which I eventually chased up to the function call not returning
a bitmap:
function myapp.getaBM(oldBM:tbitmap):tbitmap;
var bitmap:tbitmap
begin
bitmap:=tbitmap.create;
//rest bitmap initialize here
bitmap:=oldBM;
result:=bitmap;
bitmap.free; //gwan get lost result
end;
Now to me, the following quote from help seems to indicate the above code
would be right:
Any object instantiated by a call to Create should be destroyed by a call to
Free, so that the object an be properly destroyed and the memory released.
Free is successful even if the object is nil, so if the object was never
initialized, for example, calling Free wont result in an error.
And the variable RESULT is always available for use. Seems RESULT is
destroyed with the free, because the only way the code works is by using
FreeOnRelease instead, which the bible does not recommend.
OR do I leave it up to the procedure/function to destroy all the items
created within that area on exit, just like any other variable, thus
alleviating the use of Free?
Re the above I often see Try...except free xxxx in called functions or
procedures, written by others, who are much more adept than me.
Cheers,
Al+
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz