> QUESTION
> BTW, you cant free a memorystream at the end of a function,
> if u want the
> stream passed back as a result. But does the memorystream get
> released/freed
> automatically after the function has returned??
>
> EG
> I call the function like so:
> thememstream:=jpgcomment.writecommenttostream(thememstream);
>
> //external function:
> function tjpgcomment.writecommenttostream(oldS:
> TMemoryStream):TMemoryStream;
> //This is OK
> newS.CopyFrom(oldS,(i));
> Result:=newS;
> end;
>
> //This is not OK, as the result is destroyed before it
> reaches the caller
> newS.CopyFrom(oldS,(i));
> Result:=newS;
> newS.free;
> end;
A stream is basically an object, and as with all objects:
thememstream:=jpgcomment.writecommenttostream(thememstream);
try
// Do something with thememstream
finally
thememstream.Free;
end;
This assumes that jpgcomment.writecommenttostream creates the stream before
returning.
Regards,
Dennis.
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz