Joe Conway <m...@joeconway.com> writes: > Any objection if I add these two macros to libpq-fe.h? > ------------------- > + /* Useful macros for PQconnectdbParams() and PQconnectStartParams() */ > + #define DECL_PARAMS_ARRAYS(PARAMS_ARRAY_SIZE) \ > + const char **keywords = pg_malloc(PARAMS_ARRAY_SIZE * \ > + sizeof(*keywords)); \ > + const char **values = pg_malloc(PARAMS_ARRAY_SIZE * \ > + sizeof(*values)) > + #define SET_PARAMS_ARRAYS(__kv_idx__,__kv_kw__,__kv_v__) \ > + keywords[__kv_idx__] = __kv_kw__; \ > + values[__kv_idx__] = __kv_v__
Yes. Exposing pg_malloc is 100% wrong, and would be even if you'd remembered the subsequent free() ;-) It does not seem especially useful either. In most cases the array size is constant and there's no reason to not just make it a local in the calling function. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers