Quote Originally Posted by anon View Post
If the memory is freed, why wouldn't malloc be allowed to reuse it again?

So, Layer just holds the pointer but doesn't try to manage the resource in any way? From the description it sounds like a rather brittle system, but seeing some actual code might help.

One more thing that can commonly go wrong: you aren't erasing items in a vector while looping over the vector?
As I said in my previous post memory should not be freed in the undo layer. It should stay separate while I create new layers.

Layer holds a pointer and memory is freed for all layers in the vector when the tool exists.

I'm erasing in the vector by doing:
Code:
layers.erase(layers.begin()+ index);
I understand it is hard for you to understand exactly what is going on but it is not easy to post code examples... I might be able to get somthing together though.