int OBJ_NAME_new_index(unsigned long (*hash_func) (const char *),
                       int (*cmp_func) (const char *, const char *),
                       void (*free_func) (const char *, int, const char *))
{
    int ret;
    int i;
    NAME_FUNCS *name_funcs;
    if (name_funcs_stack == NULL) {
        CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);
        name_funcs_stack = sk_NAME_FUNCS_new_null();
        CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);
    }
    if (name_funcs_stack == NULL) {
        return (0);
    }
    ret = names_type_num;
    names_type_num++;
    for (i = sk_NAME_FUNCS_num(name_funcs_stack); i < names_type_num; i++) {
        CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);
        name_funcs = OPENSSL_zalloc(sizeof(*name_funcs));
        CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);
        if (name_funcs == NULL) {
            OBJerr(OBJ_F_OBJ_NAME_NEW_INDEX, ERR_R_MALLOC_FAILURE);
            return (0);
        }
        name_funcs->hash_func = lh_strhash;
        name_funcs->cmp_func = OPENSSL_strcmp;
        CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);
        sk_NAME_FUNCS_push(name_funcs_stack, name_funcs);
        CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);
    }
    name_funcs = sk_NAME_FUNCS_value(name_funcs_stack, ret);
    if (hash_func != NULL)
        name_funcs->hash_func = hash_func;
    if (cmp_func != NULL)
        name_funcs->cmp_func = cmp_func;
    if (free_func != NULL)
        name_funcs->free_func = free_func;
    return (ret);
}
['int OBJ_NAME_new_index(unsigned long (*hash_func) (const char *),\n                       int (*cmp_func) (const char *, const char *),\n                       void (*free_func) (const char *, int, const char *))\n{\n    int ret;\n    int i;\n    NAME_FUNCS *name_funcs;\n    if (name_funcs_stack == NULL) {\n        CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);\n        name_funcs_stack = sk_NAME_FUNCS_new_null();\n        CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);\n    }\n    if (name_funcs_stack == NULL) {\n        return (0);\n    }\n    ret = names_type_num;\n    names_type_num++;\n    for (i = sk_NAME_FUNCS_num(name_funcs_stack); i < names_type_num; i++) {\n        CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);\n        name_funcs = OPENSSL_zalloc(sizeof(*name_funcs));\n        CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);\n        if (name_funcs == NULL) {\n            OBJerr(OBJ_F_OBJ_NAME_NEW_INDEX, ERR_R_MALLOC_FAILURE);\n            return (0);\n        }\n        name_funcs->hash_func = lh_strhash;\n        name_funcs->cmp_func = OPENSSL_strcmp;\n        CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);\n        sk_NAME_FUNCS_push(name_funcs_stack, name_funcs);\n        CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);\n    }\n    name_funcs = sk_NAME_FUNCS_value(name_funcs_stack, ret);\n    if (hash_func != NULL)\n        name_funcs->hash_func = hash_func;\n    if (cmp_func != NULL)\n        name_funcs->cmp_func = cmp_func;\n    if (free_func != NULL)\n        name_funcs->free_func = free_func;\n    return (ret);\n}', 'int CRYPTO_mem_ctrl(int mode)\n{\n#ifdef OPENSSL_NO_CRYPTO_MDEBUG\n    return mode - mode;\n#else\n    int ret = mh_mode;\n    CRYPTO_w_lock(CRYPTO_LOCK_MALLOC);\n    switch (mode) {\n    default:\n        break;\n    case CRYPTO_MEM_CHECK_ON:\n        mh_mode = CRYPTO_MEM_CHECK_ON | CRYPTO_MEM_CHECK_ENABLE;\n        num_disable = 0;\n        break;\n    case CRYPTO_MEM_CHECK_OFF:\n        mh_mode = 0;\n        num_disable = 0;\n        break;\n    case CRYPTO_MEM_CHECK_DISABLE:\n        if (mh_mode & CRYPTO_MEM_CHECK_ON) {\n            CRYPTO_THREADID cur;\n            CRYPTO_THREADID_current(&cur);\n            if (!num_disable\n                || CRYPTO_THREADID_cmp(&disabling_threadid, &cur)) {\n                CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC);\n                CRYPTO_w_lock(CRYPTO_LOCK_MALLOC2);\n                CRYPTO_w_lock(CRYPTO_LOCK_MALLOC);\n                mh_mode &= ~CRYPTO_MEM_CHECK_ENABLE;\n                CRYPTO_THREADID_cpy(&disabling_threadid, &cur);\n            }\n            num_disable++;\n        }\n        break;\n    case CRYPTO_MEM_CHECK_ENABLE:\n        if (mh_mode & CRYPTO_MEM_CHECK_ON) {\n            if (num_disable) {\n                num_disable--;\n                if (num_disable == 0) {\n                    mh_mode |= CRYPTO_MEM_CHECK_ENABLE;\n                    CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC2);\n                }\n            }\n        }\n        break;\n    }\n    CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC);\n    return (ret);\n#endif\n}', '_STACK *sk_new_null(void)\n{\n    return sk_new((int (*)(const void *, const void *))0);\n}', '_STACK *sk_new(int (*c) (const void *, const void *))\n{\n    _STACK *ret;\n    if ((ret = OPENSSL_zalloc(sizeof(_STACK))) == NULL)\n        goto err;\n    if ((ret->data = OPENSSL_zalloc(sizeof(*ret->data) * MIN_NODES)) == NULL)\n        goto err;\n    ret->comp = c;\n    ret->num_alloc = MIN_NODES;\n    return (ret);\n err:\n    OPENSSL_free(ret);\n    return (NULL);\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 (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    (void)file;\n    (void)line;\n    ret = malloc(num);\n#endif\n#ifndef OPENSSL_CPUID_OBJ\n    if (ret && (num > 2048)) {\n        extern unsigned char cleanse_ctr;\n        ((unsigned char *)ret)[0] = cleanse_ctr;\n    }\n#endif\n    return ret;\n}', 'int sk_num(const _STACK *st)\n{\n    if (st == NULL)\n        return -1;\n    return st->num;\n}', 'int sk_push(_STACK *st, void *data)\n{\n    return (sk_insert(st, data, st->num));\n}', 'int sk_insert(_STACK *st, void *data, int loc)\n{\n    char **s;\n    if (st == NULL)\n        return 0;\n    if (st->num_alloc <= st->num + 1) {\n        s = OPENSSL_realloc((char *)st->data,\n                            (unsigned int)sizeof(char *) * st->num_alloc * 2);\n        if (s == NULL)\n            return (0);\n        st->data = s;\n        st->num_alloc *= 2;\n    }\n    if ((loc >= (int)st->num) || (loc < 0))\n        st->data[st->num] = data;\n    else {\n        memmove(&(st->data[loc + 1]),\n                &(st->data[loc]), sizeof(char *) * (st->num - loc));\n        st->data[loc] = data;\n    }\n    st->num++;\n    st->sorted = 0;\n    return (st->num);\n}']