[Pcre-svn] [166] code/trunk: Use allocator from code for pc…

トップ ページ
このメッセージを削除
著者: Subversion repository
日付:  
To: pcre-svn
題目: [Pcre-svn] [166] code/trunk: Use allocator from code for pcre2_match_data_create_from_pattern if NULL
Revision: 166
          http://www.exim.org/viewvc/pcre2?view=rev&revision=166
Author:   ph10
Date:     2014-11-28 13:23:40 +0000 (Fri, 28 Nov 2014)


Log Message:
-----------
Use allocator from code for pcre2_match_data_create_from_pattern if NULL
passed.

Modified Paths:
--------------
    code/trunk/doc/html/pcre2_match_data_create_from_pattern.html
    code/trunk/doc/html/pcre2api.html
    code/trunk/doc/pcre2.txt
    code/trunk/doc/pcre2_match_data_create_from_pattern.3
    code/trunk/doc/pcre2api.3
    code/trunk/src/pcre2_match_data.c


Modified: code/trunk/doc/html/pcre2_match_data_create_from_pattern.html
===================================================================
--- code/trunk/doc/html/pcre2_match_data_create_from_pattern.html    2014-11-28 12:46:16 UTC (rev 165)
+++ code/trunk/doc/html/pcre2_match_data_create_from_pattern.html    2014-11-28 13:23:40 UTC (rev 166)
@@ -35,8 +35,9 @@
 </P>
 <P>
 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
-the memory for the block could not be obtained.
+or is NULL to use the same memory allocator as was used for the compiled
+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


Modified: code/trunk/doc/html/pcre2api.html
===================================================================
--- code/trunk/doc/html/pcre2api.html    2014-11-28 12:46:16 UTC (rev 165)
+++ code/trunk/doc/html/pcre2api.html    2014-11-28 13:23:40 UTC (rev 166)
@@ -1709,14 +1709,18 @@
 matched string.
 </P>
 <P>
-For <b>pcre2_match_data_create_from_pattern()</b>, the first argument is a
-pointer to a compiled pattern. In this case the ovector is created to be
-exactly the right size to hold all the substrings a pattern might capture.
+The second argument of <b>pcre2_match_data_create()</b> is a pointer to a
+general context, which can specify custom memory management for obtaining the
+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>
-The second argument of both these functions is a pointer to a general context,
-which can specify custom memory management for obtaining the memory for the
-match data block. If you are not using custom memory management, pass NULL.
+For <b>pcre2_match_data_create_from_pattern()</b>, the first argument is a
+pointer to a compiled pattern. The ovector is created to be exactly the right
+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


Modified: code/trunk/doc/pcre2.txt
===================================================================
--- code/trunk/doc/pcre2.txt    2014-11-28 12:46:16 UTC (rev 165)
+++ code/trunk/doc/pcre2.txt    2014-11-28 13:23:40 UTC (rev 166)
@@ -1728,15 +1728,17 @@
        pcre2_match_data_create(), so it is always possible to return the over-
        all matched string.


-       For  pcre2_match_data_create_from_pattern(),  the  first  argument is a
-       pointer to a compiled pattern. In this case the ovector is  created  to
-       be  exactly  the  right size to hold all the substrings a pattern might
-       capture.
+       The second argument of pcre2_match_data_create() is a pointer to a gen-
+       eral context, which can specify custom memory management for  obtaining
+       the memory for the match data block. If you are not using custom memory
+       management, pass NULL, which causes malloc() to be used.


-       The second argument of both these functions is a pointer to  a  general
-       context,  which  can specify custom memory management for obtaining the
-       memory for the match data block. If you are  not  using  custom  memory
-       management, pass NULL.
+       For pcre2_match_data_create_from_pattern(), the  first  argument  is  a
+       pointer to a compiled pattern. The ovector is created to be exactly the
+       right size to hold all the substrings a pattern might capture. The sec-
+       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
        compiled patterns. When it is no longer needed, it should be  freed  by


Modified: code/trunk/doc/pcre2_match_data_create_from_pattern.3
===================================================================
--- code/trunk/doc/pcre2_match_data_create_from_pattern.3    2014-11-28 12:46:16 UTC (rev 165)
+++ code/trunk/doc/pcre2_match_data_create_from_pattern.3    2014-11-28 13:23:40 UTC (rev 166)
@@ -22,8 +22,9 @@
 the matched string and any captured substrings.
 .P
 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
-the memory for the block could not be obtained.
+or is NULL to use the same memory allocator as was used for the compiled
+pattern. The result of the function is NULL if the memory for the block could
+not be obtained.
 .P
 There is a complete description of the PCRE2 native API in the
 .\" HREF


Modified: code/trunk/doc/pcre2api.3
===================================================================
--- code/trunk/doc/pcre2api.3    2014-11-28 12:46:16 UTC (rev 165)
+++ code/trunk/doc/pcre2api.3    2014-11-28 13:23:40 UTC (rev 166)
@@ -1700,14 +1700,18 @@
 \fBpcre2_match_data_create()\fP, so it is always possible to return the overall
 matched string.
 .P
+The second argument of \fBpcre2_match_data_create()\fP is a pointer to a
+general context, which can specify custom memory management for obtaining the
+memory for the match data block. If you are not using custom memory management,
+pass NULL, which causes \fBmalloc()\fP to be used.
+.P
 For \fBpcre2_match_data_create_from_pattern()\fP, the first argument is a
-pointer to a compiled pattern. In this case the ovector is created to be
-exactly the right size to hold all the substrings a pattern might capture.
+pointer to a compiled pattern. The ovector is created to be exactly the right
+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
-The second argument of both these functions is a pointer to a general context,
-which can specify custom memory management for obtaining the memory for the
-match data block. If you are not using custom memory management, pass NULL.
-.P
 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
 \fBpcre2_match_data_free()\fP. You can extract information from a match data


Modified: code/trunk/src/pcre2_match_data.c
===================================================================
--- code/trunk/src/pcre2_match_data.c    2014-11-28 12:46:16 UTC (rev 165)
+++ code/trunk/src/pcre2_match_data.c    2014-11-28 13:23:40 UTC (rev 166)
@@ -72,10 +72,13 @@
 *  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_match_data_create_from_pattern(const pcre2_code *code,
pcre2_general_context *gcontext)
{
+if (gcontext == NULL) gcontext = (pcre2_general_context *)code;
return pcre2_match_data_create(((pcre2_real_code *)code)->top_bracket + 1,
gcontext);
}