Use allocator from code for pcre2_match_data_create_from_pattern if NULL
passed.
This commit is contained in:
parent
161cd17ba0
commit
caf78231ec
|
@ -35,8 +35,9 @@ the matched string and any captured substrings.
|
||||||
</P>
|
</P>
|
||||||
<P>
|
<P>
|
||||||
The second argument points to a general context, for custom memory management,
|
The second argument points to a general context, for custom memory management,
|
||||||
or is NULL for system memory management. The result of the function is NULL if
|
or is NULL to use the same memory allocator as was used for the compiled
|
||||||
the memory for the block could not be obtained.
|
pattern. The result of the function is NULL if the memory for the block could
|
||||||
|
not be obtained.
|
||||||
</P>
|
</P>
|
||||||
<P>
|
<P>
|
||||||
There is a complete description of the PCRE2 native API in the
|
There is a complete description of the PCRE2 native API in the
|
||||||
|
|
|
@ -1709,14 +1709,18 @@ substrings. A minimum of at least 1 pair is imposed by
|
||||||
matched string.
|
matched string.
|
||||||
</P>
|
</P>
|
||||||
<P>
|
<P>
|
||||||
For <b>pcre2_match_data_create_from_pattern()</b>, the first argument is a
|
The second argument of <b>pcre2_match_data_create()</b> is a pointer to a
|
||||||
pointer to a compiled pattern. In this case the ovector is created to be
|
general context, which can specify custom memory management for obtaining the
|
||||||
exactly the right size to hold all the substrings a pattern might capture.
|
memory for the match data block. If you are not using custom memory management,
|
||||||
|
pass NULL, which causes <b>malloc()</b> to be used.
|
||||||
</P>
|
</P>
|
||||||
<P>
|
<P>
|
||||||
The second argument of both these functions is a pointer to a general context,
|
For <b>pcre2_match_data_create_from_pattern()</b>, the first argument is a
|
||||||
which can specify custom memory management for obtaining the memory for the
|
pointer to a compiled pattern. The ovector is created to be exactly the right
|
||||||
match data block. If you are not using custom memory management, pass NULL.
|
size to hold all the substrings a pattern might capture. The second argument is
|
||||||
|
again a pointer to a general context, but in this case if NULL is passed, the
|
||||||
|
memory is obtained using the same allocator that was used for the compiled
|
||||||
|
pattern (custom or default).
|
||||||
</P>
|
</P>
|
||||||
<P>
|
<P>
|
||||||
A match data block can be used many times, with the same or different compiled
|
A match data block can be used many times, with the same or different compiled
|
||||||
|
|
|
@ -1728,15 +1728,17 @@ THE MATCH DATA BLOCK
|
||||||
pcre2_match_data_create(), so it is always possible to return the over-
|
pcre2_match_data_create(), so it is always possible to return the over-
|
||||||
all matched string.
|
all matched string.
|
||||||
|
|
||||||
For pcre2_match_data_create_from_pattern(), the first argument is a
|
The second argument of pcre2_match_data_create() is a pointer to a gen-
|
||||||
pointer to a compiled pattern. In this case the ovector is created to
|
eral context, which can specify custom memory management for obtaining
|
||||||
be exactly the right size to hold all the substrings a pattern might
|
the memory for the match data block. If you are not using custom memory
|
||||||
capture.
|
management, pass NULL, which causes malloc() to be used.
|
||||||
|
|
||||||
The second argument of both these functions is a pointer to a general
|
For pcre2_match_data_create_from_pattern(), the first argument is a
|
||||||
context, which can specify custom memory management for obtaining the
|
pointer to a compiled pattern. The ovector is created to be exactly the
|
||||||
memory for the match data block. If you are not using custom memory
|
right size to hold all the substrings a pattern might capture. The sec-
|
||||||
management, pass NULL.
|
ond argument is again a pointer to a general context, but in this case
|
||||||
|
if NULL is passed, the memory is obtained using the same allocator that
|
||||||
|
was used for the compiled pattern (custom or default).
|
||||||
|
|
||||||
A match data block can be used many times, with the same or different
|
A match data block can be used many times, with the same or different
|
||||||
compiled patterns. When it is no longer needed, it should be freed by
|
compiled patterns. When it is no longer needed, it should be freed by
|
||||||
|
|
|
@ -22,8 +22,9 @@ pairs of offsets that are required in the match data block. These form the
|
||||||
the matched string and any captured substrings.
|
the matched string and any captured substrings.
|
||||||
.P
|
.P
|
||||||
The second argument points to a general context, for custom memory management,
|
The second argument points to a general context, for custom memory management,
|
||||||
or is NULL for system memory management. The result of the function is NULL if
|
or is NULL to use the same memory allocator as was used for the compiled
|
||||||
the memory for the block could not be obtained.
|
pattern. The result of the function is NULL if the memory for the block could
|
||||||
|
not be obtained.
|
||||||
.P
|
.P
|
||||||
There is a complete description of the PCRE2 native API in the
|
There is a complete description of the PCRE2 native API in the
|
||||||
.\" HREF
|
.\" HREF
|
||||||
|
|
|
@ -1700,13 +1700,17 @@ substrings. A minimum of at least 1 pair is imposed by
|
||||||
\fBpcre2_match_data_create()\fP, so it is always possible to return the overall
|
\fBpcre2_match_data_create()\fP, so it is always possible to return the overall
|
||||||
matched string.
|
matched string.
|
||||||
.P
|
.P
|
||||||
For \fBpcre2_match_data_create_from_pattern()\fP, the first argument is a
|
The second argument of \fBpcre2_match_data_create()\fP is a pointer to a
|
||||||
pointer to a compiled pattern. In this case the ovector is created to be
|
general context, which can specify custom memory management for obtaining the
|
||||||
exactly the right size to hold all the substrings a pattern might capture.
|
memory for the match data block. If you are not using custom memory management,
|
||||||
|
pass NULL, which causes \fBmalloc()\fP to be used.
|
||||||
.P
|
.P
|
||||||
The second argument of both these functions is a pointer to a general context,
|
For \fBpcre2_match_data_create_from_pattern()\fP, the first argument is a
|
||||||
which can specify custom memory management for obtaining the memory for the
|
pointer to a compiled pattern. The ovector is created to be exactly the right
|
||||||
match data block. If you are not using custom memory management, pass NULL.
|
size to hold all the substrings a pattern might capture. The second argument is
|
||||||
|
again a pointer to a general context, but in this case if NULL is passed, the
|
||||||
|
memory is obtained using the same allocator that was used for the compiled
|
||||||
|
pattern (custom or default).
|
||||||
.P
|
.P
|
||||||
A match data block can be used many times, with the same or different compiled
|
A match data block can be used many times, with the same or different compiled
|
||||||
patterns. When it is no longer needed, it should be freed by calling
|
patterns. When it is no longer needed, it should be freed by calling
|
||||||
|
|
|
@ -72,10 +72,13 @@ return yield;
|
||||||
* Create a match data block using pattern data *
|
* Create a match data block using pattern data *
|
||||||
*************************************************/
|
*************************************************/
|
||||||
|
|
||||||
|
/* If no context is supplied, use the memory allocator from the code. */
|
||||||
|
|
||||||
PCRE2_EXP_DEFN pcre2_match_data * PCRE2_CALL_CONVENTION
|
PCRE2_EXP_DEFN pcre2_match_data * PCRE2_CALL_CONVENTION
|
||||||
pcre2_match_data_create_from_pattern(const pcre2_code *code,
|
pcre2_match_data_create_from_pattern(const pcre2_code *code,
|
||||||
pcre2_general_context *gcontext)
|
pcre2_general_context *gcontext)
|
||||||
{
|
{
|
||||||
|
if (gcontext == NULL) gcontext = (pcre2_general_context *)code;
|
||||||
return pcre2_match_data_create(((pcre2_real_code *)code)->top_bracket + 1,
|
return pcre2_match_data_create(((pcre2_real_code *)code)->top_bracket + 1,
|
||||||
gcontext);
|
gcontext);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue