]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
doc: update ref count doc in light of refactoring
authorPauli <pauli@openssl.org>
Sat, 1 Jul 2023 11:06:47 +0000 (21:06 +1000)
committerPauli <pauli@openssl.org>
Tue, 4 Jul 2023 22:33:53 +0000 (08:33 +1000)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
(Merged from https://github.com/openssl/openssl/pull/21341)

doc/internal/man3/evp_generic_fetch.pod

index ce75ffbfc878bc439ca2945e03cb3a45dac1564d..b4f625285a98def9b2448c91eba152e48c71a6d2 100644 (file)
@@ -121,6 +121,11 @@ And here's the implementation of the FOO method fetcher:
         if ((foo = OPENSSL_zalloc(sizeof(*foo))) == NULL)
             return NULL;
 
+        if (!CRYPTO_NEW_REF(&foo->refcnt, 1)) {
+            OPENSSL_free(foo);
+            return NULL;
+        }
+
         foo->name_id = name_id;
 
         for (; fns->function_id != 0; fns++) {
@@ -151,9 +156,16 @@ And here's the implementation of the FOO method fetcher:
 
     EVP_FOO_meth_free(EVP_FOO *foo)
     {
+        int i;
+
         if (foo != NULL) {
             OSSL_PROVIDER *prov = foo->prov;
 
+            CRYPTO_DOWN_REF(&foo->refcnt, &i);
+            if (i > 0)
+                return;
+
+            CRYPTO_FREE_REF(&foo->refcnt);
             OPENSSL_free(foo);
             ossl_provider_free(prov);
         }
@@ -170,7 +182,7 @@ And here's the implementation of the FOO method fetcher:
         EVP_FOO *foo = vfoo;
         int ref = 0;
 
-        CRYPTO_UP_REF(&foo->refcnt, &ref, foo_lock);
+        CRYPTO_UP_REF(&foo->refcnt, &ref);
         return 1;
     }