[Pcre-svn] [487] code/trunk: Ensure all _free() functions do…

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [487] code/trunk: Ensure all _free() functions do nothing for NULL, and document this.
Revision: 487
          http://www.exim.org/viewvc/pcre2?view=rev&revision=487
Author:   ph10
Date:     2016-02-06 12:45:56 +0000 (Sat, 06 Feb 2016)
Log Message:
-----------
Ensure all _free() functions do nothing for NULL, and document this.


Modified Paths:
--------------
    code/trunk/doc/pcre2api.3
    code/trunk/src/pcre2_substring.c


Modified: code/trunk/doc/pcre2api.3
===================================================================
--- code/trunk/doc/pcre2api.3    2016-02-05 19:39:45 UTC (rev 486)
+++ code/trunk/doc/pcre2api.3    2016-02-06 12:45:56 UTC (rev 487)
@@ -1,4 +1,4 @@
-.TH PCRE2API 3 "05 February 2016" "PCRE2 10.22"
+.TH PCRE2API 3 "06 February 2016" "PCRE2 10.22"
 .SH NAME
 PCRE2 - Perl-compatible regular expressions (revised API)
 .sp
@@ -393,9 +393,16 @@
 return a copy of the subject string with substitutions for parts that were
 matched.
 .P
+Functions whose names begin with \fBpcre2_serialize_\fP are used for saving
+compiled patterns on disc or elsewhere, and reloading them later.
+.P
 Finally, there are functions for finding out information about a compiled
 pattern (\fBpcre2_pattern_info()\fP) and about the configuration with which
 PCRE2 was built (\fBpcre2_config()\fP).
+.P
+Functions with names ending with \fB_free()\fP are used for freeing memory
+blocks of various sorts. In all cases, if one of these functions is called with
+a NULL argument, it does nothing.
 .
 .
 .SH "STRING LENGTHS AND OFFSETS"
@@ -3214,6 +3221,6 @@
 .rs
 .sp
 .nf
-Last updated: 05 February 2016
+Last updated: 06 February 2016
 Copyright (c) 1997-2016 University of Cambridge.
 .fi


Modified: code/trunk/src/pcre2_substring.c
===================================================================
--- code/trunk/src/pcre2_substring.c    2016-02-05 19:39:45 UTC (rev 486)
+++ code/trunk/src/pcre2_substring.c    2016-02-06 12:45:56 UTC (rev 487)
@@ -240,8 +240,11 @@
 PCRE2_EXP_DEFN void PCRE2_CALL_CONVENTION
 pcre2_substring_free(PCRE2_UCHAR *string)
 {
-pcre2_memctl *memctl = (pcre2_memctl *)((char *)string - sizeof(pcre2_memctl));
-memctl->free(memctl, memctl->memory_data);
+if (string != NULL)
+  {
+  pcre2_memctl *memctl = (pcre2_memctl *)((char *)string - sizeof(pcre2_memctl));
+  memctl->free(memctl, memctl->memory_data);
+  }
 }



@@ -436,8 +439,11 @@
PCRE2_EXP_DEFN void PCRE2_CALL_CONVENTION
pcre2_substring_list_free(PCRE2_SPTR *list)
{
-pcre2_memctl *memctl = (pcre2_memctl *)((char *)list - sizeof(pcre2_memctl));
-memctl->free(memctl, memctl->memory_data);
+if (list != NULL)
+ {
+ pcre2_memctl *memctl = (pcre2_memctl *)((char *)list - sizeof(pcre2_memctl));
+ memctl->free(memctl, memctl->memory_data);
+ }
}