Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
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

+2-15
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)