25 Mar
2010
25 Mar
'10
9:33 p.m.
Rainer Weikusat rweikusat@mssgmbh.com writes:
static void consume_results(struct pgsql_db *db) { do { if (!PQconsumeInput(db->pg)) break;
if (PQisBusy(db->pg)) return;
} while (PQgetResult(db->pg) != NULL);
[...]
On a related note, the PQgetResult documentation
http://www.postgresql.org/docs/8.3/interactive/libpq-async.html
states that returned PGresults should be freed with PQclear and the PQclear documentation
http://www.postgresql.org/docs/8.3/interactive/libpq-exec.html#LIBPQ-EXEC-MAIN
says You can keep a PGresult object around for as long as you need it; it does not go away when you issue a new command, nor even if you close the connection. To get rid of it, you must call PQclear. Failure to do this will result in memory leaks in your application.
so the code quoted above should result in a memory leak if it ever actually receives a PGresult.