era*_*ros 6 c++ string valgrind
Valgrind抱怨一个substr调用.
string Message::nextField(string& input) {
int posSeparator = input.find_first_of(SEPARATOR);
string temp;
temp = input.substr(0, posSeparator); //Error points to this line
input.erase(0, posSeparator + 1);
return temp;
}
Run Code Online (Sandbox Code Playgroud)
错误:
12个块中的290个字节肯定在丢失记录1中丢失1
该函数的作用基本上是解析输入,返回由SEPARATOR字符分隔的字符串部分.使用下一个定义从另一个类的方法调用此函数:
void doSomething(string input) {
input.erase(0,2);
string temp = nextField(input);
this->room = atoi(temp.c_str());
temp = input;
this->money = atoi(temp.c_str());
}
Run Code Online (Sandbox Code Playgroud)
没有别的奇怪或重要的东西可以包含在这里.我使用Eclipse Indigo的Valgrind分析中的Valgrind的默认设置.有任何想法吗?
| 归档时间: |
|
| 查看次数: |
765 次 |
| 最近记录: |