Invalid Address specified to RtlFreeHeap on Destructor
I am trying to preserve the original value of an object for use at each iteration of a loop, however on when the elements are deleted which are only in scope of the loop, I get an error which says: "Invalid Address specified to RtlFreeHeap." I can't figure out what I am doing wrong.
Here is a sample of my code:
void mainTest (Graph_ptr _dataGraph)
Graph originalDataGraph = (*_dataGraph);
for(int i=0; i<10; i++)
Graph dataGraphCopy = originalDataGraph;
Graph_ptr dataGraph = Graph_ptr(&dataGraphCopy);
// do some other things
Note this code works properly if I change the dataGraph definition to:
Graph_ptr dataGraph = _dataGraph;
However, by doing this, I lose the original value of the dataGraph which I need at the start of each loop iteration. Also, Graph_ptr is just a boost pointer of type Graph.
anyway, the way you code makes me think you might not have a proper understanding of C++ basics ( and boost smart pointer library for what matters ). I say this because coding this way in C++ is dangerous and it inevitably leads to unstable/buggy programs even when they appear working as expected. Just a friendly warning ...