PCRE2_CODE_COPY(3)
π¦ NAME π¦
PCRE2 β Perl-compatible regular expressions, but make it revised API β¨ (yes bestie, the PCRE2 manual page, this is her π )
β¨ SYNOPSIS β¨
okay so before anything else, you gotta pull her in:
#include <pcre2.h>
and then the actual star of the show, the function signature, character for character, no cap:
pcre2_code *pcre2_code_copy(const pcre2_code *code);
π DESCRIPTION π
Okay so pcre2_code_copy() makes a copy of the memory used for a compiled pattern π β and only that memory. It is not copying any memory used by the JIT compiler, bestie. None. Zero. Nada π.
Which means: unless you follow it up with a call to pcre2_jit_compile(), your little copy can be used only for non-JIT matching π. So don't come crying to me when you try to JIT-match with it. I warned you. Vibe check failed fr fr.
Also, the pointer to the character tables is copied β not the tables themselves π«Ά (if you want the actual tables to come along too, go look at pcre2_code_copy_with_tables(), she's the one who does that π
).
The yield of the function is NULL if code is NULL, or if sufficient memory cannot be obtained π. So like, check your pointers and check your malloc energy, y'know?
And if you want the whole entire lore: there's 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, they ate.
TL;DR bestie: compile β copy β no JIT memory in the copy βpcre2_jit_compile()if you want JIT β check forNULLβ character tables are just a pointer, not a photocopy π
π and that's the page, mwah π brought to you by PCRE2 10.47, dated 22 November 2016 β iconic behavior, honestly ππ
π¦ where this page comes from
- fedora 43: pcre2-devel 10.47-1.fc43 Β· BSD-3-Clause AND FSFULLR AND X11 AND GPL-2.0-or-later AND FSFAP AND FSFUL AND GPL-3.0-or-later
- fedora 43: pcre2-devel 10.47-1.fc43 Β· BSD-3-Clause AND FSFULLR AND X11 AND GPL-2.0-or-later AND FSFAP AND FSFUL AND GPL-3.0-or-later
- fedora 44: pcre2-devel 10.47-1.fc44.1 Β· BSD-3-Clause AND FSFULLR AND X11 AND GPL-2.0-or-later AND FSFAP AND FSFUL AND GPL-3.0-or-later
- fedora 44: pcre2-devel 10.47-1.fc44.1 Β· BSD-3-Clause AND FSFULLR AND X11 AND GPL-2.0-or-later AND FSFAP AND FSFUL AND GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms