Re: [PATCH v6 3/8] regex.3: Desoupify regfree() description

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Apr 21, 2023 at 01:35:43AM +0200, Alejandro Colomar wrote:
> On 4/20/23 21:37, наб wrote:
> > diff --git a/man3/regex.3 b/man3/regex.3
> > index 3f1529583..e3dd72a74 100644
> > --- a/man3/regex.3
> > +++ b/man3/regex.3
> > @@ -225,12 +225,10 @@ .SS Error reporting
> >  .IR errbuf ;
> >  the error string is always null-terminated, and truncated to fit.
> >  .SS Freeing
> > -Supplying
> >  .BR regfree ()
> > -with a precompiled pattern buffer,
> > -.IR preg ,
> > -will free the memory allocated to the pattern buffer by the compiling
> > -process,
> > +invalidates the pattern buffer at
> While this ("invalidates") is true, it omits the most important information:
> it frees the object.
It doesn't.

> I think it's better to say that it frees (or
> deallocates) the object and any memory allocated within it, since that
> already implies invalidating it (due to
> <https://port70.net/~nsz/c/c11/n1570.html#6.2.4p2> and
> <https://port70.net/~nsz/c/c11/n1570.html#7.22.3p1>),
For the precise reasons listed here:
the regex_t object continues to exist.
regcomp() doesn't allocate *preg, and regfree() doesn't deallocate it.

> and also tells why
> it's necessary to call this function.  Otherwise, it's not clear why we
> should call it.  Why would I want to invalidate a buffer?
Admittedly, it does also "free any memory allocated by regcomp( )
associated with preg." (Issue 8 Draft 2.1), yeah.
Maybe it's my neurosis that I consider "may no longer be passed to
regexec()" the primary effect here.

Updated to
  regfree() invalidates the pattern buffer at *preg, freeing any
  associated memory; *preg must have been initialized via regcomp().

Best,

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux