Use CLEARPGRES() macro to call PQclear() and set res to NULL.

This simplifies some of the error handling blocks, as now
we can unconditionally use this macro without worrying about multiple
PQclear() calls causing a double-free().

Per discussion with Daniele.
This commit is contained in:
Josh Kupershmidt
2012-12-14 20:13:23 -07:00
parent b4d8a90437
commit 7213e2fe7b
2 changed files with 25 additions and 24 deletions

View File

@ -73,4 +73,9 @@ extern void pgut_readopt(const char *path, pgut_option options[], int elevel);
extern void pgut_setopt(pgut_option *opt, const char *optarg, pgut_optsrc src);
extern bool pgut_keyeq(const char *lhs, const char *rhs);
/* So we don't need to fret over multiple calls to PQclear(), e.g.
* in cleanup labels.
*/
#define CLEARPGRES(pgres) do { PQclear(pgres); pgres = NULL; } while (0)
#endif /* PGUT_FE_H */