long TXT_DB_write(BIO *out, TXT_DB *db)
{
    long i, j, n, nn, l, tot = 0;
    char *p, **pp, *f;
    BUF_MEM *buf = NULL;
    long ret = -1;
    if ((buf = BUF_MEM_new()) == NULL)
        goto err;
    n = sk_OPENSSL_PSTRING_num(db->data);
    nn = db->num_fields;
    for (i = 0; i < n; i++) {
        pp = sk_OPENSSL_PSTRING_value(db->data, i);
        l = 0;
        for (j = 0; j < nn; j++) {
            if (pp[j] != NULL)
                l += strlen(pp[j]);
        }
        if (!BUF_MEM_grow_clean(buf, (int)(l * 2 + nn)))
            goto err;
        p = buf->data;
        for (j = 0; j < nn; j++) {
            f = pp[j];
            if (f != NULL)
                for (;;) {
                    if (*f == '\0')
                        break;
                    if (*f == '\t')
                        *(p++) = '\\';
                    *(p++) = *(f++);
                }
            *(p++) = '\t';
        }
        p[-1] = '\n';
        j = p - buf->data;
        if (BIO_write(out, buf->data, (int)j) != j)
            goto err;
        tot += j;
    }
    ret = tot;
 err:
    BUF_MEM_free(buf);
    return ret;
}
["long TXT_DB_write(BIO *out, TXT_DB *db)\n{\n    long i, j, n, nn, l, tot = 0;\n    char *p, **pp, *f;\n    BUF_MEM *buf = NULL;\n    long ret = -1;\n    if ((buf = BUF_MEM_new()) == NULL)\n        goto err;\n    n = sk_OPENSSL_PSTRING_num(db->data);\n    nn = db->num_fields;\n    for (i = 0; i < n; i++) {\n        pp = sk_OPENSSL_PSTRING_value(db->data, i);\n        l = 0;\n        for (j = 0; j < nn; j++) {\n            if (pp[j] != NULL)\n                l += strlen(pp[j]);\n        }\n        if (!BUF_MEM_grow_clean(buf, (int)(l * 2 + nn)))\n            goto err;\n        p = buf->data;\n        for (j = 0; j < nn; j++) {\n            f = pp[j];\n            if (f != NULL)\n                for (;;) {\n                    if (*f == '\\0')\n                        break;\n                    if (*f == '\\t')\n                        *(p++) = '\\\\';\n                    *(p++) = *(f++);\n                }\n            *(p++) = '\\t';\n        }\n        p[-1] = '\\n';\n        j = p - buf->data;\n        if (BIO_write(out, buf->data, (int)j) != j)\n            goto err;\n        tot += j;\n    }\n    ret = tot;\n err:\n    BUF_MEM_free(buf);\n    return ret;\n}", 'BUF_MEM *BUF_MEM_new(void)\n{\n    BUF_MEM *ret;\n    ret = OPENSSL_zalloc(sizeof(*ret));\n    if (ret == NULL) {\n        BUFerr(BUF_F_BUF_MEM_NEW, ERR_R_MALLOC_FAILURE);\n        return NULL;\n    }\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    FAILTEST();\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    INCREMENT(malloc_count);\n    if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)\n        return malloc_impl(num, file, line);\n    if (num == 0)\n        return NULL;\n    FAILTEST();\n    if (allow_customize) {\n        allow_customize = 0;\n    }\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); (void)(line);\n    ret = malloc(num);\n#endif\n    return ret;\n}', 'void BUF_MEM_free(BUF_MEM *a)\n{\n    if (a->data != NULL) {\n        if (a->flags & BUF_MEM_FLAG_SECURE)\n            OPENSSL_secure_clear_free(a->data, a->max);\n        else\n            OPENSSL_clear_free(a->data, a->max);\n    }\n    OPENSSL_free(a);\n}']