Search code examples
c++new-operatorcrypto++delete-operator

Does a filter / StringSink allocated with new require a delete?


Consider the code line:

StringSource( cipher ,
              true   ,
              new PK_DecryptorFilter( rng       ,
                                      decrypter ,
                                      new StringSink( plainText ) ) );

The filter and the StringSink object get created using new now I'm curious whether I'm responsible for deleting those as I'm unsure how I would do that since I would need the pointers to these objects.

When looking at the test projects I can't seem to find a delete so I'm guessing these objects automatically get deleted once their job is fulfillled.

But since documentations can be wrong I figured I'd make sure.


Solution

  • Looking at the header and source for those classes, both of them end up assigning their attachment to a member_ptr which deals with the deletion automatically. You shouldn't delete them yourself, just let the library handle it.