With 0.9.5a this is what I did:
created debug functions:
eg:
void
Dmalloc(void *new, int bytes, char *file, int line, int after)
{
if (!after) {
fprintf(debug_out, "DEBUG: before malloc(%d) %s:%d\n",
bytes, file, line);
} else {
fprintf(debug_out, "DEBUG: after malloc %p = malloc(%d) %s:%d\n",
new, bytes, file, line);
}
fflush(debug_out);
}
then do:
CRYPTO_set_mem_debug_functions(Dmalloc, Drealloc, Dfree, NULL, NULL);
also, when looking up the syntax I found in crypto/mem.c the following
function pointers:
/* may be changed as long as `allow_customize' is set */
static void *(*malloc_locked_func)(size_t) = malloc;
static void (*free_locked_func)(void *) = free;
static void *(*malloc_func)(size_t) = malloc;
static void *(*realloc_func)(void *, size_t)= realloc;
static void (*free_func)(void *) = free;
for which you can override with:
CRYPTO_set_mem_functions();
hope this helps.
Mike
> -----Original Message-----
> From: Jim Keohane [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, July 26, 2000 4:47 PM
> To: [EMAIL PROTECTED]
> Subject: Replacing Malloc/Free with our own in OpenSSL 0.9.4
>
>
> I need to have OpenSSL use our own malloc/free. At first I
> thought I
> would replace or redefine all Malloc's and Free's and similar items to
> use our routines. If performance became an issue I would later prune
> back to only where needed for absolute thread safety.
>
> Our environment on mainframe does not support pthreads. In making
> OpenSSL threadsafe between MVS tasks we wanted to handle all memory
> allocations ourselves.
>
> I *thought* all I had to do was change crypto/crypto.h like
>
> #if defined(OURSTUFF)
> #define Malloc OurMalloc
> #define Realloc OurRealloc
> #define FreeFunc OurFree
> #define Free(addr) OurFree(addr)
> #define Malloc_locked OurMalloc
> #define Free_locked(addr) OurFree(addr)
> #else
> #define Malloc malloc
> #define Realloc realloc
> #define FreeFunc free
> #define Free(addr) free(addr)
> #define Malloc_locked malloc
> #define Free_locked(addr) free(addr)
> #endif /* OURSTUFF */
>
> Unfortunately we crashed in a few places like pem_lib.c on a:
>
> Free(b);
>
> where b was allocated earlier in pem_lib.c via a call to
> BIG_MEM_new(...).
>
> I haven't located where BIG_MEM_new is defined or proto'd or
> whatever. Not yet anyway.
>
> Does anyone have a list of the places where changes are
> necessary? Is
> it documented somewhere that I have missed?
>
> Thanks muchly in advance! - Jim
>
>
>
> --
>
>
> Jim Keohane
> Brigadier Consultant
>
> LockStar, Inc.
> 1200 Wall Street West
> Lyndhurst, NJ 07071
>
> Tel: (201) 508-3231
> Fax: (201) 508-3201
> http://www.lockstar.com
>
> "Anyone who considers protocol unimportant has never dealt with a cat"
> -L.Long
>
>
> ______________________________________________________________________
> OpenSSL Project http://www.openssl.org
> Development Mailing List [EMAIL PROTECTED]
> Automated List Manager [EMAIL PROTECTED]
>
______________________________________________________________________
OpenSSL Project http://www.openssl.org
Development Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]