Re: allowing multiple PQclear() calls
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Josh Kupershmidt <schmiddy@gmail.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2012-12-11T07:12:17Z
Lists: pgsql-hackers
Josh Kupershmidt <schmiddy@gmail.com> writes: > Would it be crazy to add an "already_freed" flag to the pg_result > struct which PQclear() would set, or some equivalent safety mechanism, > to avoid this hassle for users? Yes, it would. Once the memory has been freed, malloc() is at liberty to give it out for some other purpose. The only way we could make that work reliably is to permanently leak the memory occupied by the PGresult ... which I trust you will agree is a cure worse than the disease. regards, tom lane