I just noticed that this is leaking a bit of memory, because we call getObjectDescription (which pallocs its result) and then cstring_to_text which pallocs a copy. This is not a lot and it's not going to live much anyway, is it worrying about? I reworked it like this:
{ char *description = NULL; text *tdesc; ... description = getObjectDescription(&address); tdesc = cstring_to_text(description); pfree(description); PG_RETURN_TEXT_P(tdesc); } I notice that ruleutils.c has a convenience function string_to_text which is designed to avoid this problem: static text * string_to_text(char *str) { text *result; result = cstring_to_text(str); pfree(str); return result; } So I could just make that non-static (though I'd move it to varlena.c while at it) and use that instead. I wonder if it's worth going through some of the other callers of cstring_to_text and change them to use this wrapper. There are some that are leaking some memory, though it's a tiny amount and I'm not sure it's worth the bother. (But if so, why is ruleutils going the extra mile?) -- Álvaro Herrera <alvhe...@commandprompt.com> The PostgreSQL Company - Command Prompt, Inc. PostgreSQL Replication, Consulting, Custom Development, 24x7 support -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers