I would go along with Robert, you should not return complex types from
functions that create them, It makes the code messy, you create it in
one place and free it in another. Any sort of code analyser would also
complain about this. You could return a string = stringlist.text and
assign it to a local stringlist.
Jeremy Coulter wrote:
Hi All. This is a question that might be infulenced by some serious
lack of sleep :-)
I have a funtion. Its return result is a TStringlist.
In my code I create a TStringlist then add my values to it, then pass
this to the RESULT varaible for the function.
Now, this is prob. an obvious answer than I prob. do actually know,
but if I got:-
sResult := TStringList.create;
sResult.add('blah');
Result:=sResult;
Then if I free sResult, then I loss the values I added, and the result
is empty as you would expect.
But the issue I have is, so if I DONT free sResults, what happens to
it? Surley it stays in memory,a dn I would end up with a memory leack
after repeaditive calls. Is that right? Or is because the variable is
function specific its free by default etc?
Its a basic question I know....but the more I thought about it the
more uncertain I became....I really need some sleep so that prob. the
real probelm :-)
Jeremy
------------------------------------------------------------------------
_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: delphi@delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to [EMAIL PROTECTED] with Subject: unsubscribe
--
*Rohit Gupta*
* B.E. Elec. M.E. Mem IEEE Associate IEE*
*Technical Manager*
*Computer Fanatics Limited*
**
*Tel* +64 9 4892280
*Fax* +64 9 4892290
*Email [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>**
*Web *www.cfl.co.nz <http://www.cfl.co.nz/>
------------------------------------------------------------------------
This email and any attachments contain information, which is
confidential and may be subject to legal privilege and copyright. If you
are not the intended recipient, you must not use, distribute or copy
this email or attachments. If you have received this in error, please
notify us immediately by return email and then delete this email and any
attachments.
_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: delphi@delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to [EMAIL PROTECTED] with Subject: unsubscribe