` New and Dispose (Robert Peros) - Icetips Article
Icetips - Templates, Tools & Utilities for Clarion Developers

Templates, Tools and Utilities
for Clarion Developers

Icetips Article

Back to article list   Search Articles     Add Comment     Printer friendly     Direct link  

Clarion in general: New and Dispose
2005-01-07 -- Robert Peros
 
Newsgroups: softvelocity.clarion.language > Several months ago, maybe in 2003, there was an interesting discussion > about how to deal with situations where you need to NEW a variable in > a method but you can't dispose of it easily, such as: > > MyMethod Procedure(String pS) > NewS &String > Code > NewS &= NEW STRING(Size(pS)*2) > NewS = pS & pS > Return(NewS) > > You can't dispose of this and this would cause memory leak (as far as > I know) Some people posted a really nifty way to call the method back > to dispose of the variable but I have lost this and don't remember > exactly how it was done. Anyone recall this? No,but if I correct understand, look at the ABFILE.clw(again :-)) ! Choose the buffer size for a given string ! Must be at least one byte but other than that may clip ! Then allocate string and copy in value DupString PROCEDURE(STRING St)!,*STRING SizeIs SIGNED,AUTO NS &STRING,AUTO CODE SizeIs = LEN(CLIP(St)) NS &= NEW STRING (CHOOSE(SizeIs = 0,1,SizeIs)) NS = St RETURN NS Return value is ref. to STRING and you have responsibility for DISPOSE time. R.


Today is November 23, 2024, 5:10 pm
This article has been viewed 35216 times.
Google search has resulted in 4 hits on this article since January 25, 2004.



Back to article list   Search Articles   Add Comment   Printer friendly

Login

User Name:

Password: