static int expand(OPENSSL_LHASH *lh)
{
    OPENSSL_LH_NODE **n, **n1, **n2, *np;
    unsigned int p, pmax, nni, j;
    unsigned long hash;
    nni = lh->num_alloc_nodes;
    p = lh->p;
    pmax = lh->pmax;
    if (p + 1 >= pmax) {
        j = nni * 2;
        n = OPENSSL_realloc(lh->b, sizeof(OPENSSL_LH_NODE *) * j);
        if (n == NULL) {
            lh->error++;
            return 0;
        }
        lh->b = n;
        memset(n + nni, 0, sizeof(*n) * (j - nni));
        lh->pmax = nni;
        lh->num_alloc_nodes = j;
        lh->num_expand_reallocs++;
        lh->p = 0;
    } else {
        lh->p++;
    }
    lh->num_nodes++;
    lh->num_expands++;
    n1 = &(lh->b[p]);
    n2 = &(lh->b[p + pmax]);
    *n2 = NULL;
    for (np = *n1; np != NULL;) {
        hash = np->hash;
        if ((hash % nni) != p) {
            *n1 = (*n1)->next;
            np->next = *n2;
            *n2 = np;
        } else
            n1 = &((*n1)->next);
        np = *n1;
    }
    return 1;
}
['STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file)\n{\n    BIO *in = BIO_new(BIO_s_file());\n    X509 *x = NULL;\n    X509_NAME *xn = NULL;\n    STACK_OF(X509_NAME) *ret = NULL;\n    LHASH_OF(X509_NAME) *name_hash = lh_X509_NAME_new(xname_hash, xname_cmp);\n    if ((name_hash == NULL) || (in == NULL)) {\n        SSLerr(SSL_F_SSL_LOAD_CLIENT_CA_FILE, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    if (!BIO_read_filename(in, file))\n        goto err;\n    for (;;) {\n        if (PEM_read_bio_X509(in, &x, NULL, NULL) == NULL)\n            break;\n        if (ret == NULL) {\n            ret = sk_X509_NAME_new_null();\n            if (ret == NULL) {\n                SSLerr(SSL_F_SSL_LOAD_CLIENT_CA_FILE, ERR_R_MALLOC_FAILURE);\n                goto err;\n            }\n        }\n        if ((xn = X509_get_subject_name(x)) == NULL)\n            goto err;\n        xn = X509_NAME_dup(xn);\n        if (xn == NULL)\n            goto err;\n        if (lh_X509_NAME_retrieve(name_hash, xn) != NULL) {\n            X509_NAME_free(xn);\n            xn = NULL;\n        } else {\n            lh_X509_NAME_insert(name_hash, xn);\n            if (!sk_X509_NAME_push(ret, xn))\n                goto err;\n        }\n    }\n    goto done;\n err:\n    X509_NAME_free(xn);\n    sk_X509_NAME_pop_free(ret, X509_NAME_free);\n    ret = NULL;\n done:\n    BIO_free(in);\n    X509_free(x);\n    lh_X509_NAME_free(name_hash);\n    if (ret != NULL)\n        ERR_clear_error();\n    return ret;\n}', 'DEFINE_LHASH_OF(X509_NAME)', 'OPENSSL_LHASH *OPENSSL_LH_new(OPENSSL_LH_HASHFUNC h, OPENSSL_LH_COMPFUNC c)\n{\n    OPENSSL_LHASH *ret;\n    if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL)\n        return NULL;\n    if ((ret->b = OPENSSL_zalloc(sizeof(*ret->b) * MIN_NODES)) == NULL)\n        goto err;\n    ret->comp = ((c == NULL) ? (OPENSSL_LH_COMPFUNC)strcmp : c);\n    ret->hash = ((h == NULL) ? (OPENSSL_LH_HASHFUNC)OPENSSL_LH_strhash : h);\n    ret->num_nodes = MIN_NODES / 2;\n    ret->num_alloc_nodes = MIN_NODES;\n    ret->pmax = MIN_NODES / 2;\n    ret->up_load = UP_LOAD;\n    ret->down_load = DOWN_LOAD;\n    return ret;\nerr:\n    OPENSSL_free(ret->b);\n    OPENSSL_free(ret);\n    return NULL;\n}', 'void *OPENSSL_LH_insert(OPENSSL_LHASH *lh, void *data)\n{\n    unsigned long hash;\n    OPENSSL_LH_NODE *nn, **rn;\n    void *ret;\n    lh->error = 0;\n    if ((lh->up_load <= (lh->num_items * LH_LOAD_MULT / lh->num_nodes)) && !expand(lh))\n        return NULL;\n    rn = getrn(lh, data, &hash);\n    if (*rn == NULL) {\n        if ((nn = OPENSSL_malloc(sizeof(*nn))) == NULL) {\n            lh->error++;\n            return NULL;\n        }\n        nn->data = data;\n        nn->next = NULL;\n        nn->hash = hash;\n        *rn = nn;\n        ret = NULL;\n        lh->num_insert++;\n        lh->num_items++;\n    } else {\n        ret = (*rn)->data;\n        (*rn)->data = data;\n        lh->num_replace++;\n    }\n    return ret;\n}', 'static int expand(OPENSSL_LHASH *lh)\n{\n    OPENSSL_LH_NODE **n, **n1, **n2, *np;\n    unsigned int p, pmax, nni, j;\n    unsigned long hash;\n    nni = lh->num_alloc_nodes;\n    p = lh->p;\n    pmax = lh->pmax;\n    if (p + 1 >= pmax) {\n        j = nni * 2;\n        n = OPENSSL_realloc(lh->b, sizeof(OPENSSL_LH_NODE *) * j);\n        if (n == NULL) {\n            lh->error++;\n            return 0;\n        }\n        lh->b = n;\n        memset(n + nni, 0, sizeof(*n) * (j - nni));\n        lh->pmax = nni;\n        lh->num_alloc_nodes = j;\n        lh->num_expand_reallocs++;\n        lh->p = 0;\n    } else {\n        lh->p++;\n    }\n    lh->num_nodes++;\n    lh->num_expands++;\n    n1 = &(lh->b[p]);\n    n2 = &(lh->b[p + pmax]);\n    *n2 = NULL;\n    for (np = *n1; np != NULL;) {\n        hash = np->hash;\n        if ((hash % nni) != p) {\n            *n1 = (*n1)->next;\n            np->next = *n2;\n            *n2 = np;\n        } else\n            n1 = &((*n1)->next);\n        np = *n1;\n    }\n    return 1;\n}']