struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i)
{
    CRYPTO_dynlock *pointer = NULL;
    if (i)
        i = -i - 1;
    CRYPTO_w_lock(CRYPTO_LOCK_DYNLOCK);
    if (dyn_locks != NULL && i < sk_CRYPTO_dynlock_num(dyn_locks))
        pointer = sk_CRYPTO_dynlock_value(dyn_locks, i);
    if (pointer)
        pointer->references++;
    CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);
    if (pointer)
        return pointer->data;
    return NULL;
}
['BN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, int lock,\n                                    const BIGNUM *mod, BN_CTX *ctx)\n{\n    BN_MONT_CTX *ret;\n    CRYPTO_r_lock(lock);\n    ret = *pmont;\n    CRYPTO_r_unlock(lock);\n    if (ret)\n        return ret;\n    ret = BN_MONT_CTX_new();\n    if (ret == NULL)\n        return NULL;\n    if (!BN_MONT_CTX_set(ret, mod, ctx)) {\n        BN_MONT_CTX_free(ret);\n        return NULL;\n    }\n    CRYPTO_w_lock(lock);\n    if (*pmont) {\n        BN_MONT_CTX_free(ret);\n        ret = *pmont;\n    } else\n        *pmont = ret;\n    CRYPTO_w_unlock(lock);\n    return ret;\n}', 'void CRYPTO_lock(int mode, int type, const char *file, int line)\n{\n#ifdef LOCK_DEBUG\n    {\n        CRYPTO_THREADID id;\n        char *rw_text, *operation_text;\n        if (mode & CRYPTO_LOCK)\n            operation_text = "lock  ";\n        else if (mode & CRYPTO_UNLOCK)\n            operation_text = "unlock";\n        else\n            operation_text = "ERROR ";\n        if (mode & CRYPTO_READ)\n            rw_text = "r";\n        else if (mode & CRYPTO_WRITE)\n            rw_text = "w";\n        else\n            rw_text = "ERROR";\n        CRYPTO_THREADID_current(&id);\n        fprintf(stderr, "lock:%08lx:(%s)%s %-18s %s:%d\\n",\n                CRYPTO_THREADID_hash(&id), rw_text, operation_text,\n                CRYPTO_get_lock_name(type), file, line);\n    }\n#endif\n    if (type < 0) {\n        if (dynlock_lock_callback != NULL) {\n            struct CRYPTO_dynlock_value *pointer\n                = CRYPTO_get_dynlock_value(type);\n            OPENSSL_assert(pointer != NULL);\n            dynlock_lock_callback(mode, pointer, file, line);\n            CRYPTO_destroy_dynlockid(type);\n        }\n    } else if (locking_callback != NULL)\n        locking_callback(mode, type, file, line);\n}', 'void CRYPTO_destroy_dynlockid(int i)\n{\n    CRYPTO_dynlock *pointer = NULL;\n    if (i)\n        i = -i - 1;\n    if (dynlock_destroy_callback == NULL)\n        return;\n    CRYPTO_w_lock(CRYPTO_LOCK_DYNLOCK);\n    if (dyn_locks == NULL || i >= sk_CRYPTO_dynlock_num(dyn_locks)) {\n        CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);\n        return;\n    }\n    pointer = sk_CRYPTO_dynlock_value(dyn_locks, i);\n    if (pointer != NULL) {\n        --pointer->references;\n#ifdef REF_CHECK\n        if (pointer->references < 0) {\n            OPENSSL_showfatal("CRYPTO_destroy_dynlockid, bad reference count\\n");\n            abort();\n        } else\n#endif\n        if (pointer->references <= 0) {\n            (void)sk_CRYPTO_dynlock_set(dyn_locks, i, NULL);\n        } else\n            pointer = NULL;\n    }\n    CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);\n    if (pointer) {\n        dynlock_destroy_callback(pointer->data, __FILE__, __LINE__);\n        OPENSSL_free(pointer);\n    }\n}', 'void CRYPTO_free(void *str)\n{\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_free(str, 0);\n        free(str);\n        CRYPTO_mem_debug_free(str, 1);\n    } else {\n        free(str);\n    }\n#else\n    free(str);\n#endif\n}', 'struct CRYPTO_dynlock_value *CRYPTO_get_dynlock_value(int i)\n{\n    CRYPTO_dynlock *pointer = NULL;\n    if (i)\n        i = -i - 1;\n    CRYPTO_w_lock(CRYPTO_LOCK_DYNLOCK);\n    if (dyn_locks != NULL && i < sk_CRYPTO_dynlock_num(dyn_locks))\n        pointer = sk_CRYPTO_dynlock_value(dyn_locks, i);\n    if (pointer)\n        pointer->references++;\n    CRYPTO_w_unlock(CRYPTO_LOCK_DYNLOCK);\n    if (pointer)\n        return pointer->data;\n    return NULL;\n}']