Window Class Memory
I've got some questions about window class memory - the memory you allocate by setting the cbClsExtra member of a WNDCLASS(EX) to a value greater than 0.
The problem I have is this: I want to store some strings I loaded from somewhere, which will remain the same for all instances of the window class. So it would be a good idea to load these strings once and store pointers to them in the class extra memory.
Which begs the question of initialization/deinitialization. Initialization is the easy part: In WM_CREATE, I can simply check if the pointers are NULL, and if they are, load the strings.
I can't deinitialize them in WM_DESTROY. I don't know if there are other windows of the same class, who I would steal the memory from. (And heaven help me if those windows run in a different thread.)
Neither can I deinitialize it at any later point, because there is no way to access the memory without an actual window instance.
It would be possible to reserve even more memory and implement reference counting, but is it worth it? Are there better alternatives?
You could just leave the memory to be released on process termination.
>> It would be possible to reserve even more memory and implement reference counting, but is it worth it? <<
It's only four bytes...