CTLOG *CTLOG_new(EVP_PKEY *public_key, const char *name)
{
    CTLOG *ret = CTLOG_new_null();
    if (ret == NULL)
        return NULL;
    ret->name = OPENSSL_strdup(name);
    if (ret->name == NULL) {
        CTerr(CT_F_CTLOG_NEW, ERR_R_MALLOC_FAILURE);
        goto err;
    }
    ret->public_key = public_key;
    if (ct_v1_log_id_from_pkey(public_key, ret->log_id) != 1)
        goto err;
    return ret;
err:
    CTLOG_free(ret);
    return NULL;
}
['CTLOG *CTLOG_new(EVP_PKEY *public_key, const char *name)\n{\n    CTLOG *ret = CTLOG_new_null();\n    if (ret == NULL)\n        return NULL;\n    ret->name = OPENSSL_strdup(name);\n    if (ret->name == NULL) {\n        CTerr(CT_F_CTLOG_NEW, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    ret->public_key = public_key;\n    if (ct_v1_log_id_from_pkey(public_key, ret->log_id) != 1)\n        goto err;\n    return ret;\nerr:\n    CTLOG_free(ret);\n    return NULL;\n}', 'CTLOG *CTLOG_new_null(void)\n{\n    CTLOG *ret = OPENSSL_zalloc(sizeof(*ret));\n    if (ret == NULL)\n        CTerr(CT_F_CTLOG_NEW_NULL, ERR_R_MALLOC_FAILURE);\n    return ret;\n}', 'void *CRYPTO_zalloc(size_t num, const char *file, int line)\n{\n    void *ret = CRYPTO_malloc(num, file, line);\n    if (ret != NULL)\n        memset(ret, 0, num);\n    return ret;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\n    if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)\n        return malloc_impl(num, file, line);\n    if (num <= 0)\n        return NULL;\n    allow_customize = 0;\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_malloc(NULL, num, 0, file, line);\n        ret = malloc(num);\n        CRYPTO_mem_debug_malloc(ret, num, 1, file, line);\n    } else {\n        ret = malloc(num);\n    }\n#else\n    osslargused(file); osslargused(line);\n    ret = malloc(num);\n#endif\n    return ret;\n}', 'char *CRYPTO_strdup(const char *str, const char* file, int line)\n{\n    char *ret;\n    size_t size;\n    if (str == NULL)\n        return NULL;\n    size = strlen(str) + 1;\n    ret = CRYPTO_malloc(size, file, line);\n    if (ret != NULL)\n        memcpy(ret, str, size);\n    return ret;\n}', 'static int ct_v1_log_id_from_pkey(EVP_PKEY *pkey,\n                                  unsigned char log_id[CT_V1_HASHLEN])\n{\n    int ret = 0;\n    unsigned char *pkey_der = NULL;\n    int pkey_der_len = i2d_PUBKEY(pkey, &pkey_der);\n    if (pkey_der_len <= 0) {\n        CTerr(CT_F_CT_V1_LOG_ID_FROM_PKEY, CT_R_LOG_KEY_INVALID);\n        goto err;\n    }\n    SHA256(pkey_der, pkey_der_len, log_id);\n    ret = 1;\nerr:\n    OPENSSL_free(pkey_der);\n    return ret;\n}', 'int i2d_PUBKEY(EVP_PKEY *a, unsigned char **pp)\n{\n    X509_PUBKEY *xpk = NULL;\n    int ret;\n    if (!a)\n        return 0;\n    if (!X509_PUBKEY_set(&xpk, a))\n        return 0;\n    ret = i2d_X509_PUBKEY(xpk, pp);\n    X509_PUBKEY_free(xpk);\n    return ret;\n}', 'void CRYPTO_free(void *str, const char *file, int line)\n{\n    if (free_impl != NULL && free_impl != &CRYPTO_free) {\n        free_impl(str, file, line);\n        return;\n    }\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_free(str, 0, file, line);\n        free(str);\n        CRYPTO_mem_debug_free(str, 1, file, line);\n    } else {\n        free(str);\n    }\n#else\n    free(str);\n#endif\n}']