PCRE2_CODE_COPY(3)

πŸ’– NAME πŸ’–

okay so bestie, this page is PCRE2_CODE_COPY(3) and it lives in the Library Functions Manual β€” it's all about PCRE2 β€” Perl-compatible regular expressions (revised API). iconic, honestly. ✨


🌸 SYNOPSIS 🌸

#include <pcre2.h>

pcre2_code *pcre2_code_copy_with_tables(const pcre2_code *code);

πŸ¦‹ DESCRIPTION πŸ¦‹

so this function makes a copy of the memory used for a compiled pattern, but it excludes any memory used by the JIT compiler. no cap. 🫢

without a subsequent call to pcre2_jit_compile(), the copy can be used only for non-JIT matching. periodt.

unlike pcre2_code_copy(), a separate copy of the character tables is also made, with the new code pointing to it. the way that's lowkey important iykyk πŸ’…

this memory will be automatically freed when pcre2_code_free() is called. slay, no manual cleanup drama. πŸŽ€

the yield of the function is NULL if code is NULL or if sufficient memory cannot be obtained. 😭

there is 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 those bestie, they're giving main character energy. πŸ‘‘


fr fr: keep the JIT situation in mind β€” without pcre2_jit_compile(), that copy is only for non-JIT matching. πŸ’€

peace out πŸ’œ β€” this page is from PCRE2 10.47, dated 16 January 2017. mwah πŸ’…βœ¨

πŸ“¦ where this page comes from