PCRE2_JIT_STACK_CREATE(3)

πŸ’… PCRE2_JIT_STACK_CREATE πŸ’…

okay bestie, so this page lives in the Library Functions Manual, and it's all about PCRE2 β€” yes, that's Perl-compatible regular expressions (revised API), the whole entire vibe. Sit down, grab a strawberry πŸ“, we're talking JIT stacks.


✨ SYNOPSIS ✨

like, here's the whole thing, exactly as it appears:

#include <pcre2.h>

pcre2_jit_stack *pcre2_jit_stack_create(size_t startsize,
  size_t maxsize, pcre2_general_context *gcontext);

no cap, that's it 🫢


πŸŽ€ DESCRIPTION πŸŽ€

so, what does this icon actually do? this function creates a stack for the code that the JIT compiler compiled. yep. the JIT-compiled code needs somewhere to put its stuff, and this is how you make that somewhere. πŸ’…

the first two arguments are the glow-up plan for the stack: startsize is the starting size, and maxsize is the maximum size it's allowed to grow to. it's giving "start small, dream big" ✨

the final argument is a general context β€” that's for the memory allocation functions β€” or NULL if you want standard memory allocation. honestly? NULL is fine, she's easy like that.

the result can be handed off to the JIT runtime code by calling pcre2_jit_stack_assign(), which associates the stack with a compiled pattern, and that pattern can then be processed by pcre2_match() or pcre2_jit_match(). the whole friend group, matching together 🫢

πŸ’‘ real talk: a maximum stack size of 512KiB to 1MiB should be more than enough for any pattern. like, any. don't overthink it, don't over-allocate it, she doesn't need it.

and if the stack couldn't be allocated, or the values you passed were not reasonable?? NULL comes back. 😭 that's the fail state, bestie, no workaround here, just check for it.

for more details, the manpage says to see the pcre2jit page β€” that's where the deep lore lives 🧚

there's also a complete description of the PCRE2 native API in the pcre2api page, and a description of the POSIX API in the pcre2posix page. go read them when you're ready to level up πŸ‘‘


and that's the page, periodt 🌈 this whole thing is from PCRE2 10.47, dated 23 January 2023, and it's PCRE2_JIT_STACK_CREATE(3) β€” she ate, no crumbs, mwah πŸ’–

πŸ“¦ where this page comes from