Ensure all _free() functions do nothing for NULL, and document this.

This commit is contained in:
ph10 2016-02-06 12:45:56 +00:00
parent 6be7402551
commit 7fb9eeed8a
2 changed files with 19 additions and 6 deletions

View File

@ -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 @@ The function \fBpcre2_substitute()\fP can be called to match a pattern and
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 @@ Cambridge, England.
.rs
.sp
.nf
Last updated: 05 February 2016
Last updated: 06 February 2016
Copyright (c) 1997-2016 University of Cambridge.
.fi

View File

@ -240,8 +240,11 @@ Returns: nothing
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 @@ Returns: nothing
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);
}
}