Link to home
Start Free TrialLog in
Avatar of sageryd
sagerydFlag for Sweden

asked on

Pointers

Would it be wrong not to free "B" in GetImage? Because if I do, there's an AV, and if I don't it works fine. Below is a simplification of the real code, removed irrelevant information:


procedure TMainForm.SomeProcedure;
begin
  Image1.Picure.Bitmap:=GetImage; //Image1 is a TImage
end;

function TMainForm.GetImage: TBitmap;
var B: TBitmap;
begin
  B:=TBitmap.Create;              
  B.Assign(ADODataSet.FieldByName('Image'));
  Result:=B;
end;

thx
Avatar of sfock
sfock

yes it would be wrong to free the Bitmap in GetImage,
Avatar of Lukasz Zielinski
function TMainForm.GetImage: TBitmap;
begin
 Result:=TBitmap.Create;              
 Result.Assign(ADODataSet.FieldByName('Image'));
end;
no problem with destroying B :-))
ziolko.
ASKER CERTIFIED SOLUTION
Avatar of sfock
sfock

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sageryd

ASKER

Exactly my thought, thanks for the verification. ;)

Ziolko, thanks for the simplification. Though I will reward sfock the points since he made the explanation in human text.


OOH I LOVE E-E :)
ok no problem:-)
ziolko.
Avatar of sageryd

ASKER

Unless of course you need points I could get reward ye some aswell ;)  haha
:-) I'll take my points when I deserve them.
ziolko.
Avatar of sageryd

ASKER

Either way!

*Grawrlph*