PCRE2_CONV...EXT_CREATE(3)

πŸ’… NAME πŸ’…

PCRE2 β€” Perl-compatible regular expressions (revised API) ✨

okay so real talk, this is a page from the Library Functions Manual, and it's about one little function that makes you a convert context. yes bestie, a whole manpage for one function. she's short and she's iconic, we move πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <pcre2.h>

pcre2_convert_context *pcre2_convert_context_create(
  pcre2_general_context *gcontext);

like, that's the whole thing. two arguments of nothing, one return value. simple. elegant. slay πŸ¦‹


✨ DESCRIPTION ✨

okay so picture this: there's an experimental set of pattern conversion functions in PCRE2, and this one β€” pcre2_convert_context_create() β€” is the little helper that spins up the party for you. what it does is it creates and initializes a brand new convert context, fresh out the box, ready to go 🫢

and the way memory works here, iykyk:

  • if the argument gcontext is NULL, then malloc() gets called to grab the memory it needs
  • otherwise (like, if you actually passed something in), the memory allocation function inside the general context is what gets used instead

and here's the vibe check on failure 😭 β€” if the memory could not be obtained, the result comes back as NULL. that's it, that's the error handling, no cap. so fr fr, check your return value before you use it.

ngl the important word in that first sentence is experimental β€” these pattern conversion functions are an experimental set, so don't be shocked if things shift around. treat her with the respect a slightly-unfinished icon deserves πŸ‘‘

and if you wanna know what all the pattern conversion functions actually do? they're described over in the pcre2convert documentation. go read that bestie, it's the main character of this whole saga πŸ“–


🌸 a lil sign-off 🌸

this page was brought to you by PCRE2 10.47, dated 12 July 2017, and the header up top reads PCRE2_CONV...EXT_CREATE(3) (yes the title is truncated, no we're not fixing it, she's perfect as she is πŸ’–). now go forth and convert those patterns, you absolute legend πŸ§šβ­πŸ‘‘

πŸ“¦ where this page comes from