0

I have parasoft my solution and I am getting 3 errors which are the same, "Objects to manage resources should be used instead" These errors are coming from a struct I've created. How can I remove this without altering my struct? "pointer name" pointer

DorkMonstuh
  • 819
  • 2
  • 19
  • 38

2 Answers2

1

It's probably saying you should use some sort of smart pointers to manage dynamically created objects instead of new and delete.

Luchian Grigore
  • 253,575
  • 64
  • 457
  • 625
  • could you elaborate on that please. At the moment I am creating a new node with the new keyword and I'm getting parasoft errors on the left and right branches of the node. I'm also getting one of these errors on the root of the tree and the root is defined as a member variable and a pointer to it. I don't know if this will help you elaborate please. – DorkMonstuh Apr 30 '12 at 18:14
  • Yes I have looked at smart pointers but don't really understand it. I don't relaly know how to use it in this context. – DorkMonstuh Apr 30 '12 at 18:30
  • @JohnLam you're supposed to use smart pointers instead of raw pointers. – Luchian Grigore Apr 30 '12 at 18:31
  • How does one convert this code into a smart pointer? Node* newNode = new Node; . – DorkMonstuh Apr 30 '12 at 18:37
  • @JohnLam something like `typedef SmartPtr NodePtr; NodePtr pNode(new Node);` – Luchian Grigore Apr 30 '12 at 18:38
  • Must one use a library in order to use the functionality of a smart pointer as I am getting an error saying smartptr is not a template – DorkMonstuh Apr 30 '12 at 18:43
  • 1
    @JohnLam SmartPtr was just an example. You can use a boost implementation, or std::shared_ptr or std::unique_ptr – Luchian Grigore Apr 30 '12 at 18:44
0

You can go to the quality task view to look at the violation that is being generated. From there you can right click on the violation and select "View Rule Documentation" this will give you an idea of what the violation is flagging and also give you some sample code on how to fix the violation.

If you want to just ignore the violation you can either disable the rule in your test configuration or suppress the violation. This can be done by right clicking on the violation and selecting "Suppress Task"