Re: [pcre-dev] A test for the memory mismatch problem

Αρχική Σελίδα
Delete this message
Συντάκτης: Philip Hazel
Ημερομηνία:  
Προς: Sheri
Υ/ο: pcre-dev
Αντικείμενο: Re: [pcre-dev] A test for the memory mismatch problem
On Thu, 29 Mar 2007, Sheri wrote:

> Came up with this, haven't tried it yet. Would appreciate if you review
> my additions and tell me what should be there for the callout lines.


OK. It was late in my day. I was wrong about the callout - as the
default is "no callout", the same trick isn't relevant. Also, the two
kinds of malloc default to the same thing, so we only need two
functions, not four. So we are left with this:

-------------------------------------------------------------------
#ifdef _WIN32
#include <malloc.h>

void* malloc_stub(size_t N)
{ return malloc(N); }

void free_stub(void* p)
{ free(p); }

void *(*pcre_malloc)(size_t) = &malloc_stub;
void (*pcre_free)(void *) = &free_stub;
void *(*pcre_stack_malloc)(size_t) = &malloc_stub;
void (*pcre_stack_free)(void *) = &free_stub;

#else

void *(*pcre_malloc)(size_t) = malloc;
void (*pcre_free)(void *) = free;
void *(*pcre_stack_malloc)(size_t) = malloc;
void (*pcre_stack_free)(void *) = free;

#endif


int (*pcre_callout)(pcre_callout_block *) = NULL;
-------------------------------------------------------------------


But whether that will help at all, I don't know.


Philip

--
Philip Hazel, University of Cambridge Computing Service.