当我弹出时,我收到"pointer being freed was not allocated"错误
When I pop, i get "pointer being freed was not allocated" error
这是我遇到问题的一小段代码。变位符函数返回正确的结果(带有变位符的字符串向量的向量)。除了最后一个元素为空之外,这个向量中充满了正确的变位符。因此,我尝试弹出它,但我总是收到一个"释放的指针未分配"错误
int main(int argc, const char * argv[]) {
Dictionary d = create_dictionary("dico.txt");
vector<vector<string> > v = anagrams("object", d, 0);
v.pop_back(); //Error here
return 0;
}
当涉及到"v.pop_back();"行时,会出现错误:"对象0x3000000003的malloc:***错误:未分配释放的指针"。
我想在pop_back之前发布内存的状态,但我不能发布图像,因为这是我的第一个问题,但以下是pop_back前v的内容:
v = {
[0] {
[0] "cob"
[1] "jet"
}
[1] {
[0] "object"
}
[2] { }
}
我找遍了所有能找的地方,什么也没找到=/有人知道它是从哪里来的吗?感谢您抽出时间;)
以下是我创建词典的方法:
Dictionary create_dictionary(const string& filename) {
Dictionary d;
//Read the file and store the words in d.words
ifstream file(filename.c_str());
string word;
if(file.is_open()) {
while (!file.eof()) {
file >> word;
d.words.push_back(word);
}
}
else
cout << "There is a problem with the file !" << endl;
file.close();
return d; }
如果v不为空,则调用pop_back,如:
if (!v.empty())
v.pop_back();
相关文章:
- 删除分配的 (?) 指针时"Pointer being freed was not allocated"
- D-lang being faster than C++?
- C++编译错误,"malloc: *** error for object: pointer being freed was not allocated"
- 创建一个移动分配函数,不断得到"pointer being freed was not allocated"
- C++ "Pure Virtual Function Being Called"失败
- qt resources qrc not being found
- 解析 csv 文件,"malloc: *** error for object 0x7ffeeb4f4b80: pointer being freed was not allocated"出现此错误
- C++ "pointer being freed was not allocated"
- 构造函数未被调用并"pointer being freed was not allocated"错误
- std::random_shuffle not being seeded
- "A uses B, which is being defined"是什么意思?
- C++: strcmp being ignored
- 结构"pointer being freed was not allocated"
- OnKillFocus not being called
- 当我弹出时,我收到"pointer being freed was not allocated"错误
- 调试"malloc error: pointer being freed was not allocated" ,使用 gdb
- 在堆上创建的对象是否可以被视为C++中的'being on stack'?
- 未命名的命名空间和 iostream 会导致"!= being illegal operation"
- 又是"pointer being freed was not allocated"
- 仅在模拟器中" malloc error pointer being freed was not allocated "错误: