/[pcre]/code/trunk/doc/pcrejit.3
ViewVC logotype

Diff of /code/trunk/doc/pcrejit.3

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 686 by ph10, Tue Sep 6 16:06:36 2011 UTC revision 691 by ph10, Sun Sep 11 14:31:21 2011 UTC
# Line 47  You have to do two things to make use of Line 47  You have to do two things to make use of
47    (1) Call \fBpcre_study()\fP with the PCRE_STUDY_JIT_COMPILE option for    (1) Call \fBpcre_study()\fP with the PCRE_STUDY_JIT_COMPILE option for
48        each compiled pattern, and pass the resulting \fBpcre_extra\fP block to        each compiled pattern, and pass the resulting \fBpcre_extra\fP block to
49        \fBpcre_exec()\fP.        \fBpcre_exec()\fP.
50    .sp
51    (2) Use \fBpcre_free_study()\fP to free the \fBpcre_extra\fP block when it is    (2) Use \fBpcre_free_study()\fP to free the \fBpcre_extra\fP block when it is
52        no longer needed instead of just freeing it yourself. This        no longer needed instead of just freeing it yourself. This
53        ensures that any JIT data is also freed.        ensures that any JIT data is also freed.
54  .sp  .sp
55  In some circumstances you may need to call additional functions. These are  In some circumstances you may need to call additional functions. These are
# Line 149  is given when there is not enough stack. Line 149  is given when there is not enough stack.
149  managing blocks of memory for use as JIT stacks.  managing blocks of memory for use as JIT stacks.
150  .P  .P
151  The \fBpcre_jit_stack_alloc()\fP function creates a JIT stack. Its arguments  The \fBpcre_jit_stack_alloc()\fP function creates a JIT stack. Its arguments
152  are a starting size and a maximum size, and it returns a pointer to an opaque  are a starting size and a maximum size, and it returns a pointer to an opaque
153  structure of type \fBpcre_jit_stack\fP, or NULL if there is an error. The  structure of type \fBpcre_jit_stack\fP, or NULL if there is an error. The
154  \fBpcre_jit_stack_free()\fP function can be used to free a stack that is no  \fBpcre_jit_stack_free()\fP function can be used to free a stack that is no
155  longer needed. (For the technically minded: the address space is allocated by  longer needed. (For the technically minded: the address space is allocated by
156  mmap or VirtualAlloc.)  mmap or VirtualAlloc.)
157  .P  .P
158  JIT uses far less memory for recursion than the interpretive code,  JIT uses far less memory for recursion than the interpretive code,
159  and a maximum stack size of 512K to 1M should be more than enough for any  and a maximum stack size of 512K to 1M should be more than enough for any
160  pattern.  pattern.
161  .P  .P
# Line 197  This is a suggestion for how a typical m Line 197  This is a suggestion for how a typical m
197  .sp  .sp
198    During thread initalization    During thread initalization
199      thread_local_var = pcre_jit_stack_alloc(...)      thread_local_var = pcre_jit_stack_alloc(...)
200    .sp
201    During thread exit    During thread exit
202      pcre_jit_stack_free(thread_local_var)      pcre_jit_stack_free(thread_local_var)
203    .sp
204    Use a one-line callback function    Use a one-line callback function
205      return thread_local_var      return thread_local_var
206  .sp  .sp
# Line 214  successful study with PCRE_STUDY_JIT_COM Line 214  successful study with PCRE_STUDY_JIT_COM
214  .rs  .rs
215  .sp  .sp
216  This is a single-threaded example that specifies a JIT stack without using a  This is a single-threaded example that specifies a JIT stack without using a
217  callback.  callback.
218  .sp  .sp
219    int rc;    int rc;
220    int ovector[30];    int ovector[30];
# Line 232  callback. Line 232  callback.
232    /* Check results */    /* Check results */
233    pcre_free(re);    pcre_free(re);
234    pcre_free_study(extra);    pcre_free_study(extra);
235    pcre_jit_stack_free(jit_stack);    pcre_jit_stack_free(jit_stack);
236  .sp  .sp
237  .  .
238  .  .

Legend:
Removed from v.686  
changed lines
  Added in v.691

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12