I'm trying to delete pointers in a map, but it is giving an error at the delete
part:
std::map<uint, std::vector<double>*> m;
std::map<uint, std::vector<double>*>::iterator it;
for(it = m.begin(); it != m.end(); ++it) {
delete it->second;
}
* Error in ...: free(): invalid size: 0x000000000a06ca30 *
The vectors in the map definitely exist and contain a few values. I'm obviously missing something?
Edit: This is how I insert or update the vectors:
std::vector<double>* v = new std::vector<double>;
// add something to v
std::pair<std::map<uint, std::vector<double>*>::iterator, bool> ret = m.insert(std::pair<uint, std::vector<double>*>(i, v));
if(ret.second == false) {
delete ret.first->second;
ret.first->second = v;
}
Thanks in advance.