Re: [pcre-dev] External memory allocator interface

Top Page
Delete this message
Author: Roman Rybalko
Date:  
To: pcre-dev
Subject: Re: [pcre-dev] External memory allocator interface
Philip Hazel wrote:
>> I'm going to use pcre in an embedded system,
>> so I need an external memory allocator interface in pcre.
>>
> There already is one. It has been there from the start. Scan the pcreapi
> man page for "pcre_malloc".
>

Yes, but I need an additional pointer passed to my malloc(), like this:
void* my_malloc(void *ctx, size_t size);
void* my_realloc(void *ctx, void *ptr, size_t size);
void my_free(void *ctx, void *ptr);

I'm going to make this calls:
pcre *pcre_mm_compile(const pcre_mm *mm, const char *pattern, int
options, ...);
pcre *pcre_mm_compile2(const pcre_mm *mm, ...);
int pcre_mm_exec(const pcre_mm *mm, const pcre *code, ...);
void *pcre_mm_malloc(const pcre_mm *mm, size_t size);
void pcre_mm_free(const pcre_mm *mm, void *ptr);
...

typedef struct pcre_mm {
    void *(*malloc)(void *ctx, size_t);
    void  (*free)(void *ctx, void *ptr);
    void *ctx;
} pcre_mm;


I'll place them in additional pcre_mm.h file.
Will it be suitable?

--
WBR,

Roman Rybalko