c++ - CppCheck does not detect memory leak -
have following code, cppcheck(1.68) detects "style" error.
abstracttelegram *telegramfactory::creategetwigwagparametertelegram(byte address_i, byte subaddress_i, byte tag_i) { signdatawigwag *pwigwag = new signdatawigwag(); return new sendtelegram(subaddress_i, tag_i, telegram::get_wig_wag,null,0); }
output:
variable 'pwigwag' assigned value never used. variable 'pwigwag' assigned value never used.
any options tune?
i cppcheck developer.
actually.. can't see there memory leak in code.
there classes has automatic memory management.
imagine example signdatawigwag constructor has such code:
signdatawigwag::signdatawigwag() { instances.push_back(this); }
then can deleted later using instance:
void deleteallinstances() { while (!instances.empty()) { delete instances.back(); instances.pop_back(); } }
this not unusual. popular class libraries has lots of classes kind of memory management manual delete not needed..
Comments
Post a Comment