>Unfortunately the way the original SSLeay (and now OpenSSL) ASN1 works
>is to be "memory based"

As almost everyone finds out sooner or later, memory fragmentation can soon
become an issue in the performance of long-running servers.  The ASN1
functions are particularly prone to this.  I would love to see OpenSSL have
something like this:
        typedef struct mem_alloc_funcs_s_t {
                char* malloc(void*, size_t);
                char* realloc(void*, char*, size_t)
                void free(void*, char*);
                void* arg;
        } mem_alloc_funcs_t;
This becomes an additional parameter for all the i2d, et al, functions.
(Passing in NULL would default to the regular malloc family now used.)

Here's how Apache might use this.  First, write the wrapper functions,
as in:
        char* wrap_ap_palloc(void* arg, size_t size)
        {
                return ap_pool_palloc((struct pool*)arg, size);
        }
Then define a global variable that has the function pointers filled in:
        mem_alloc_functions_t apache_template = {
                wrap_ap_palloc,
                wrap_ap_prealloc /* left as an exercise... :)*/
                wrap_ap_free,
                NULL
        };

Then, in my module code I might do:
        hook_mine(request_req* r)
        {
                mem_alloc_functions_t m = apache_template;
                m.arg = r->pool;
                ...
                d2i_X509(&cert, &bufptr, length, &m);
        }
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to