>From reading the code, it appears that OpenSSL is perfectly
happy to have BIOs statically allocated.  For instance,

    BIO bio;

    if(!BIO_set(&bio,BIO_s_socket())) {
        ERR_print_errors_fp(stderr);
        return 0;
    }
    BIO_set_fd(&bio, fd, 0);

appears effectively equivalent to dynamic allocation:

    BIO *bio;

    bio = BIO_new(BIO_s_socket());
    if(!bio) {
        return 0;
    }
    BIO_set_fd(&bio, fd, 0);

Except how do I free the BIO?  BIO_free always calls
OpenSSL_free() on the passed pointer.  Is there an
equivalent to BIO_free that will work on statically
allocated data?

    STATIC           DYNAMIC
    ------           -------
    BIO_set   <->    BIO_new
    BIO_???   <->    BIO_free


If there is no dual, then it would be a trivial change
to split BIO_free into BIO_clear (static) and BIO_free
(dynamic):

    int BIO_clear()
    {
        (everything in BIO_free except for OpenSSL_free)
    }

    int BIO_free(BIO *bio)
    {
        int ret=BIO_clear(bio);
        if(!ret) return ret;
        OpenSSL_free(bio);
        return 1;
    }

Would a patch be accepted?

I sure hope it's possible to statically allocate BIOs.
My application will be allocating >50,000 of them and
many older implementations of malloc tend to get grumpy
at those quanitities.

Thanks,

    - Scott


______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to