[pcre-dev] [Bug 1174] New: allow passing of pcre_{malloc, fr…

Góra strony
Delete this message
Autor: Gertjan Halkes
Data:  
Dla: pcre-dev
Nowe tematy: [pcre-dev] [Bug 1174] allow passing of pcre_{malloc, free, stack_malloc, stack_free, callout} as parameters
Temat: [pcre-dev] [Bug 1174] New: allow passing of pcre_{malloc, free, stack_malloc, stack_free, callout} as parameters
------- You are receiving this mail because: -------
You are on the CC list for the bug.

http://bugs.exim.org/show_bug.cgi?id=1174
           Summary: allow passing of
                    pcre_{malloc,free,stack_malloc,stack_free,callout} as
                    parameters
           Product: PCRE
           Version: N/A
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: wishlist
          Priority: medium
         Component: Code
        AssignedTo: ph10@???
        ReportedBy: eximbugz@???
                CC: pcre-dev@???



Currently, pcre uses global variables for the malloc/free and callout routines.
This makes it very precarious to use pcre as the regex library for other
libraries, because there is no control over what the library client may do with
those variables. For example, it is basically unsafe to use the callout feature
from a library, because the library client may set the pcre_callout variable to
something different (perhaps even from a different thread), causing the
callouts to go to the wrong function.

Also, if the library client for example sets the pcre_malloc variable to some
pooled allocation function, and the memory pool gets released before the
library is done with the regular expression, this will create problems. And
similarly if the library uses a pooled allocation function by setting
pcre_malloc, the library client may get into trouble.

In short, when using pcre from a library, you have to warn your library's users
that they can't touch pcre_malloc etc., because it may break your library.

It would be very nice if there were some way to pass these functions as a
parameter where they are needed. For the pcre_exec function this would be
fairly easy to add, by adding a few extra members to the pcre_extra struct and
a flag to indicate that it should use those instead of the global ones. Now I
guess that it would be hard to add this behaviour to the pcre_compile function,
because the pcre_compile function doesn't take an "extra" argument like the
pcre_exec function does.


--
Configure bugmail: http://bugs.exim.org/userprefs.cgi?tab=email