diff options
author | Thomas Munro <tmunro@postgresql.org> | 2023-04-08 21:55:28 +1200 |
---|---|---|
committer | Thomas Munro <tmunro@postgresql.org> | 2023-04-08 22:09:17 +1200 |
commit | 6db75edb2ecbc9f6912f90b671b01ab4ac3a01b0 (patch) | |
tree | 3131464af8d79aa5d4679c9c4ebb18cf2c5fce6c | |
parent | 4f51429dd7f194e36af32b557ecdce555b5ab51b (diff) | |
download | postgresql-6db75edb2ecbc9f6912f90b671b01ab4ac3a01b0.tar.gz postgresql-6db75edb2ecbc9f6912f90b671b01ab4ac3a01b0.zip |
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
-rw-r--r-- | contrib/pg_trgm/trgm_regexp.c | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/contrib/pg_trgm/trgm_regexp.c b/contrib/pg_trgm/trgm_regexp.c index 06cd3db67be..1d369460671 100644 --- a/contrib/pg_trgm/trgm_regexp.c +++ b/contrib/pg_trgm/trgm_regexp.c @@ -549,22 +549,9 @@ createTrgmNFA(text *text_re, Oid collation, REG_ADVANCED | REG_NOSUB, collation); #endif - /* - * Since the regexp library allocates its internal data structures with - * malloc, we need to use a PG_TRY block to ensure that pg_regfree() gets - * done even if there's an error. - */ - PG_TRY(); - { - trg = createTrgmNFAInternal(®ex, graph, rcontext); - } - PG_FINALLY(); - { - pg_regfree(®ex); - } - PG_END_TRY(); + trg = createTrgmNFAInternal(®ex, graph, rcontext); - /* Clean up all the cruft we created */ + /* Clean up all the cruft we created (including regex) */ MemoryContextSwitchTo(oldcontext); MemoryContextDelete(tmpcontext); |