` Comment on an Icetips Article
Icetips - Templates, Tools & Utilities for Clarion Developers

Templates, Tools and Utilities
for Clarion Developers

Add a comment to an Icetips Article

Please add your comments to this article. Please note that you must provide both a name and a valid email address in order for us to publish your comment. Comments are moderated and are not visible until they have been approved. Spam is never approved!

Your Name:  
Email:  
Header text/Subject:  

Please enter your comment in the box below:

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

Clarion in general: New and Dispose
2005-01-06 -- Jim Kane
 
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? > Why not DISPOSE the string in your calling code when you are through with > it? > > StrPtr &= MyMethod( ArnorsStr ) > > IF ~StrPtr &= NULL > DISPOSE( StrPtr ) > END that would be my vote although I dont bother to test for null: StrPtr &= MyMethod( ArnorsStr ) DISPOSE( StrPtr ) it has the advantage of immediately disposing of a potentially large string before calling 'mymethod' a second time. Jim Kane


Today is November 21, 2024, 6:55 am
This article has been viewed 35213 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: