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
pull/137/head
Thomas Munro 2 years ago
parent 4f51429dd7
commit 6db75edb2e
  1. 15
      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(&regex, graph, rcontext);
}
PG_FINALLY();
{
pg_regfree(&regex);
}
PG_END_TRY();
/* Clean up all the cruft we created */
/* Clean up all the cruft we created (including regex) */
MemoryContextSwitchTo(oldcontext);
MemoryContextDelete(tmpcontext);

Loading…
Cancel
Save