I have the following code:
QPair<QSharedPointer<unsigned int>, int> someclass::somefunction() {
int siz = data_size();
QSharedPointer<unsigned int> buffer(new unsigned int[siz]);
// Fill the buffer...
return qMakePair(buffer, siz);
}
At some point, the QSharedPointer
returned by this function will go out of scope and the pointer set in the constructor will be free'd. Using valgrind 3.6.1, I get a "Mismatched free() / delete / delete[]" error. Is there anything wrong with my use of QSharedPointer
or do I just have to live with this valgrind warning?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…