How can I tell lint to track a custodial pointer to a vector?

扶醉桌前 提交于 2019-12-24 00:18:47

问题


I have some code that loops and news up some pointers and stores them in a vector:

std::vector<InputBox*> m_octets; 
...  
InputBox* octet = new InputBox(rect, title, touch_num);
m_octets.push_back(octet);

In the class destructor I for_each over m_octets and invoke the destructor for each pointer. I think this is all good. It all compiles and the unit tests pass. The problem is Gimpel's PC-lint doesn't like it. It sees that `octet' is a custodial pointer that has not been freed (Warning 429). I can of course disable that warning but the manual (11.2.1) indicates there is a semantic for this. I would have thought would work:

-sem(*push_back, custodial (1))

Unfortunately it has no effect. I've tried various combinations including fully specifying m_octets.push_back but nothing seems to work. Does anybody know the proper form of this command for the example given?


回答1:


This one works fine for me: -sem(std::vector::push_back, custodial(1))



来源:https://stackoverflow.com/questions/12080004/how-can-i-tell-lint-to-track-a-custodial-pointer-to-a-vector

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!