PCRE_ASSIGN_JIT_STACK(3)
π PCRE_ASSIGN_JIT_STACK π
okay bestie, so this page is literally all about PCRE β that's Perl-compatible regular expressions β and specifically the pcre_assign_jit_stack function. it's a Library Functions Manual situation, and honestly? it's giving "i control the vibes of your regex memory" energy. π¦
β¨ SYNOPSIS β¨
here's the tea, copy-pasted with love:
#include <pcre.h>
void pcre_assign_jit_stack(pcre_extra *extra,
pcre_jit_callback callback, void *data);
void pcre16_assign_jit_stack(pcre16_extra *extra,
pcre16_jit_callback callback, void *data);
void pcre32_assign_jit_stack(pcre32_extra *extra,
pcre32_jit_callback callback, void *data);
yes there are three of them (8-bit, 16-bit, 32-bit, the whole girl group π ) and yes they all do the same thing. periodt.
πΈ DESCRIPTION πΈ
so like. this function gives you control over the memory used as a stack at run-time when you call pcre[16|32]_exec() on a pattern that's been successfully compiled with JIT optimization. iykyk β JIT means just-in-time, and it needs a stack, and this is where you get to pick which one. π
the arguments are:
extraβ the data pointer returned bypcre[16|32]_study()callbackβ a callback functiondataβ a JIT stack or a value to be passed to the callback function
π the vibe check: what actually happens
there's basically a little flowchart and honestly it ate:
- If
callbackisNULLanddataisNULL, an internal 32K block on the machine stack is used. easy, no thoughts, default behavior. - If
callbackisNULLanddatais notNULL, thendatamust be a valid JIT stack β the result of callingpcre[16|32]_jit_stack_alloc(). no fake stacks bestie, it has to be the real thing. - If
callbackis notNULL, it is called withdataas an argument at the start of matching, in order to set up a JIT stack. if the result isNULL, the internal 32K stack is used; otherwise the return value must be a valid JIT stack, the result of callingpcre[16|32]_jit_stack_alloc(). π«Ά
π§ threads, bestie, please listen
You may safely assign the same JIT stack to multiple patterns, as long as they are all matched in the same thread. π§΅
In a multithread application, each thread must use its own JIT stack. no sharing, no borrowing, no "it's fine" β it is not fine. π
For more details, see the pcrejit page. it's the deep dive if you want it.
π where to learn more
There is a complete description of the PCRE native API in the pcreapi page and a description of the POSIX API in the pcreposix page. go read those, they're iconic. β
ngl the whole thing is: pick your stack, don't cross the threads, and make sure any stack you hand over actually came from pcre[16|32]_jit_stack_alloc(). that's the whole assignment. π
and that's the page!! this one's from PCRE 8.30, dated 24 June 2012 β yeah she's vintage but she's still slaying π bye bestie, go allocate responsibly πβ¨
π¦ where this page comes from
- alpine 3.22: pcre-doc 8.45-r4 Β· BSD-3-Clause
- alpine 3.23: pcre-doc 8.45-r4 Β· BSD-3-Clause
- alpine 3.24: pcre-doc 8.45-r4 Β· BSD-3-Clause
- arch rolling: pcre 8.45-5 Β· BSD
- centos-stream 9: pcre-devel 8.44-4.el9 Β· BSD
- centos-stream 9: pcre-devel 8.44-4.el9 Β· BSD
- debian bookworm: libpcre3-dev 2:8.39-15
- fedora 43: pcre-devel 8.45-1.fc43.9 Β· BSD-3-Clause
- fedora 43: pcre-devel 8.45-1.fc43.9 Β· BSD-3-Clause
- fedora 44: pcre-devel 8.45-1.fc43.9 Β· BSD-3-Clause
- fedora 44: pcre-devel 8.45-1.fc43.9 Β· BSD-3-Clause
- nixos 26.05: pcre 8.45
- nixos 26.05: pcre-cpp 8.45
- opensuse-leap 16.0: pcre-devel 8.45-160000.2.2 Β· BSD-3-Clause
- opensuse-leap 16.0: pcre-devel 8.45-160000.2.2 Β· BSD-3-Clause
- opensuse-leap 16.0: pcre-devel 8.45-160000.2.2 Β· BSD-3-Clause
- opensuse-leap 16.0: pcre-devel 8.45-160000.2.2 Β· BSD-3-Clause
- ubuntu jammy: libpcre3-dev 2:8.39-13build5
- ubuntu jammy: libpcre3-dev 2:8.39-13ubuntu0.22.04.1
- ubuntu noble: libpcre3-dev 2:8.39-15build1
- ubuntu questing: libpcre3-dev 2:8.39-15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms