- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I am getting a mismatched allocation/deallocation error. It's strange becamse it happens on new and delete lines. The deallocation error is on the line that is commented //DEALLOCATION, and the corresponding allocation error is on the comment //ALLOCATION. The code that causes this problem is below. I've attached the inspector results. Is this a legitimate error?
I suspect that it is because the program crashes in the Free() function when the destructor is called. However I'm pretty sure I'm doing the right thing.
m_list is a STL vector. I've also tried using a C++ array with the same results. Platform is VC 2008. I've tried compiling with Intel compiler and also with VC 2005 with the same crashing effect.
Thanks for any help.
Nils
I am getting a mismatched allocation/deallocation error. It's strange becamse it happens on new and delete lines. The deallocation error is on the line that is commented //DEALLOCATION, and the corresponding allocation error is on the comment //ALLOCATION. The code that causes this problem is below. I've attached the inspector results. Is this a legitimate error?
I suspect that it is because the program crashes in the Free() function when the destructor is called. However I'm pretty sure I'm doing the right thing.
m_list is a STL vector. I've also tried using a C++ array with the same results. Platform is VC 2008. I've tried compiling with Intel compiler and also with VC 2005 with the same crashing effect.
Thanks for any help.
Nils
[bash] ICAPHPG::~ICAPHPG() { Free(); } ICAPHPG::ICAPHPG() { } bool ICAPHPG::Allocate(int count_in) { //m_list.reserve(count_in); //m_list.resize(count_in); m_hpgCount = count_in; return true; } void ICAPHPG::Free() { for (unsigned int i = 0; i < m_list.size(); i++) { if (m_list != NULL) delete m_list; //DEALLOCATE } } bool ICAPHPG::loadHPG(int idx, const char* path) { if (idx < 0 || idx >= m_hpgCount) return false; hpgns::CircularHPG* h = new hpgns::CircularHPG((char*)path); //ALLOCATE if (h == NULL) return false; else if (h->GetError()) return false; m_list.push_back(h); return true; } [/bash]
Link Copied
0 Replies
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page