http://bugs.winehq.org/show_bug.cgi?id=27168
--- Comment #28 from Ilya Konovalov aragaer@gmail.com 2011-09-18 12:35:25 CDT --- (In reply to comment #27)
(In reply to comment #24)
Just an idea - currently Context_Release accepts a dataContextFree pointer to a function which will free a data context once its reference count is down to 0. Now we need some way to free a certStore when reference counter on a link in that store is down to 0. Is adding something like linkContextFree a good idea?
linkContextFree implies it'd only be done on link contexts? I don't think that's true. I think you need to increment the ref count of a cert's (/CRL's/CTL's) store when returning a cert (/CRL/CTL) from the store, e.g. from CertEnumCertificatesInStore, and decrement the store's ref count when freeing it. The difficulty comes in cascading the ref count to all the stores the cert is in, e.g. if the store is part of a collection. That's really pretty complicated, because collections know which stores are part of them, but stores do not know which stores they belong to.
CertEnumCertificatesInStore actually returns not data context, but link context (or at least that's what I'm seeing). On the other hand, data context doesn't know that it has a link to it which is stored in some store - only link does. When we perform CertFreeCertificateContext on a link (and what we're getting from Enum and Query are both links) we have to catch the fact that it is the only pointer to temporary store before we descend to actual data context below it. linkContextFree would perform actions needed to remove the context from stores it belongs to. And in case of temporary store remove the store itself.