{
EVP_CIPHER *cipher = OPENSSL_zalloc(sizeof(EVP_CIPHER));
- if (cipher != NULL) {
- cipher->lock = CRYPTO_THREAD_lock_new();
- if (cipher->lock == NULL) {
- OPENSSL_free(cipher);
- return NULL;
- }
- cipher->refcnt = 1;
+ if (cipher != NULL && !CRYPTO_NEW_REF(&cipher->refcnt, 1)) {
+ OPENSSL_free(cipher);
+ return NULL;
}
return cipher;
}
int ref = 0;
if (cipher->origin == EVP_ORIG_DYNAMIC)
- CRYPTO_UP_REF(&cipher->refcnt, &ref, cipher->lock);
+ CRYPTO_UP_REF(&cipher->refcnt, &ref);
return 1;
}
{
OPENSSL_free(cipher->type_name);
ossl_provider_free(cipher->prov);
- CRYPTO_THREAD_lock_free(cipher->lock);
+ CRYPTO_FREE_REF(&cipher->refcnt);
OPENSSL_free(cipher);
}
if (cipher == NULL || cipher->origin != EVP_ORIG_DYNAMIC)
return;
- CRYPTO_DOWN_REF(&cipher->refcnt, &i, cipher->lock);
+ CRYPTO_DOWN_REF(&cipher->refcnt, &i);
if (i > 0)
return;
evp_cipher_free_int(cipher);