私は以下のコードを持っています:
std::string myName = "BLABLABLA";
//check if there are illegal characters
for (unsigned int i = 0; i < myName.length(); i++)
{
const char& c = myName[i];
if (!(isalnum(c) || (c == '_') || (c == '-')))
{
return 0;
}
}
これは、行「const char&c =myName[i];」でのvalgrindの出力です。
==17249== 51 bytes in 1 blocks are possibly lost in loss record 116 of 224
==17249== at 0x4C2714E: operator new(unsigned long) (vg_replace_malloc.c:261)
==17249== by 0x602A498: std::string::_Rep::_S_create(unsigned long, unsigned long,
std::allocator<char> const&) (in /usr/lib64/libstdc++.so.6.0.16)
==17249== by 0x602A689: std::string::_M_mutate(unsigned long, unsigned long,
unsigned long) (in /usr/lib64/libstdc++.so.6.0.16)
==17249== by 0x602AFB5: std::string::_M_leak_hard() (in
/usr/lib64/libstdc++.so.6.0.16)
==17249== by 0x602B0A4: std::string::operator[](unsigned long) (in /
/usr/lib64/libstdc++.so.6.0.16)
これには何の問題もありません...