![]() |
C++ : "new" gives me the same pointer twice
Hi,
I'm not sure what's happening here: Fereastra is an instance of fereastra allocated with new. I don't remember deleting Fereastra. To be a bit more certain I used IsBadReadPtr to see if Fereastra is cleared, but it seams ok. I want to allocate FereastraIcoana with new. I end up with FereastraIcoana having the same address as Fereastra. Code:
//test to see if Fereastra is ok Do you have any ideas? It's the end of the day and I can't get any further with this error :( I'm using Microsoft Visual c++ 2008 Thank you :) |
Show where you allocate the memory for Fereastra and show us the implementation of IsBadReadPtr.
I would do more checking to be certain that you aren't deleting the Fereastra pointer at some point. You could put a breakpoint inside the destructor to know for sure. |
The code is to big to post here. That was my thought too, that I deleted the object somewhere... Thank you for the idea of a breakpoint inside the destructor, didn't think of that :)
That function (IsBadReadPtr) is a windows function. They say that it doesn't work for all pointers, but if it says it is bad, it is for sure bad :p I don't know where the problem was, but I changed something from a vector of objects to a vector of pointers to objects and it seams to work now. Maybe the Fereastra class in which I am is read twice from that vectror... I hope it won't show up later... |
| All times are GMT +1. The time now is 03:57 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.