Milan,
I have to admit, "release" is a somewhat confusing method name.
Janitor.release() tells the Janitor to no longer look after the memory -
i.e. release control back to the calling process.
So the Janitor is used here so that if anything throws an exception
anywhere in the function, the Janitor will clean up the Reference being
worked on. However, if we get to the end, then the Janitor releases the
reference back to the owning Signature object which then takes
respsonsibility for deleting it.
So if VC6 is reporting it is not deleted, then it would appear the
Signature class is not cleaning out the references properly - which is
strange, because this is all tested in xtest which should pick up any
memory leaks in this.
Cheers,
Berin
>
> Please, could someone explain to me what this peace of code
> means (DSIGSignedInfo::createReference()):
>
> {
> DSIGReference * ref;
> XSECnew(ref, DSIGReference(mp_env));
> Janitor<DSIGReference> j_ref(ref);
>
> ...
>
> // Add to the reference List
> j_ref.release();
> mp_referenceList->addReference(ref);
>
> return ref;
> }
>
> What is Janitor::release() method for? It is not documented in
> the source (Janitor.hpp) and I couldn't find info on Google. VC6
> debugger reports that memory allocated on the second line (XSECnew())
> was never released. If Janitor was used here for freeing "ref" pointer,
> then why "ref" was returned (last line)?
>
> Thank you,
> Milan