Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » TreeCtrl » A [TreeCtrl] bug
Re: A [TreeCtrl] bug [message #14595 is a reply to message #14558] Tue, 04 March 2008 13:16 Go to previous messageGo to previous message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
As far as I can see Mirek's version is the correct fix here.
luzr wrote on Mon, 03 March 2008 18:17

Note that Null asignments there are rather intended to release the memory....

mr_ped wrote on Tue, 04 March 2008 11:38

Quote:

key = Null is nessary. for memory release.

Why? I don't see any connection between those two in C++.
Although I admit it's a good practice in C++ to always null your pointers after you released the allocated memory they are pointing to, so you don't access the freed memory by accident and rather get exception from null pointer, but actually it's "memory release for key = null", not "key = null for memory release", the reason and the consequence are the other way around.

I believe this is because both key and value are Value types that may contain reference-counted objects (such as Image), and setting Null is required to decrement this count and (perhaps) free the memory. So setting Null is can be the cause of memory release.

But if this is the case then surely 'key = Null' should be added? I admit it's unlikely that a reference counted object would be used as a Key, but it seems to be cost-free and doesn't break any code so why not do it?

I could be wrong about all this though, my understanding of this aspect of Upp is somewhat limited.

James

[Updated on: Tue, 04 March 2008 13:18]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: FIX - Single Click does not open/close items
Next Topic: problem in Refreshing at end of tree
Goto Forum:
  


Current Time: Sat May 11 20:31:19 CEST 2024

Total time taken to generate the page: 0.02558 seconds