Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
试图找出为什么只有不到 1% 的时间我有写入内存的问题。好像从一个随机线程它无法写入。我想知道铸造是否不稳定?
char *str = (char*)q_str.toStdString().c_str(); memcpy(m_list + m_count + m_length, str, strlen(str)); m_count++;
toStdString()返回一个临时的。这个临时在分号处被销毁,此时str成为一个悬空指针。做了
toStdString()
str
string s = q_str.toStdString(); memcpy(m_list + m_count + m_length, s.c_str(), s.length());