Skip to content

Commit 6db75ed

Browse files
committed
Update contrib/trgm_regexp's memory management.
While no code change was necessary for this code to keep working, we don't need to use PG_TRY()/PG_FINALLY() with explicit clean-up while working with regexes anymore. Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/CA%2BhUKGK3PGKwcKqzoosamn36YW-fsuTdOPPF1i_rtEO%3DnEYKSg%40mail.gmail.com
1 parent 4f51429 commit 6db75ed

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

contrib/pg_trgm/trgm_regexp.c

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -549,22 +549,9 @@ createTrgmNFA(text *text_re, Oid collation,
549549
REG_ADVANCED | REG_NOSUB, collation);
550550
#endif
551551

552-
/*
553-
* Since the regexp library allocates its internal data structures with
554-
* malloc, we need to use a PG_TRY block to ensure that pg_regfree() gets
555-
* done even if there's an error.
556-
*/
557-
PG_TRY();
558-
{
559-
trg = createTrgmNFAInternal(&regex, graph, rcontext);
560-
}
561-
PG_FINALLY();
562-
{
563-
pg_regfree(&regex);
564-
}
565-
PG_END_TRY();
552+
trg = createTrgmNFAInternal(&regex, graph, rcontext);
566553

567-
/* Clean up all the cruft we created */
554+
/* Clean up all the cruft we created (including regex) */
568555
MemoryContextSwitchTo(oldcontext);
569556
MemoryContextDelete(tmpcontext);
570557

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy