From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Joe Conway <mail(at)joeconway(dot)com> |
Cc: | Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>, "Hackers (PostgreSQL)" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: proposed PQconnectdbParams macros (was Re: [BUGS] BUG #5304: psql using conninfo fails in connecting to the server) |
Date: | 2010-02-04 01:10:29 |
Message-ID: | 22663.1265245829@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs pgsql-hackers |
Joe Conway <mail(at)joeconway(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Dan Baldev | 2010-02-04 02:32:45 | BUG #5312: I NEED HELP |
Previous Message | Bruce Momjian | 2010-02-04 00:42:21 | Re: BUG #5308: How to disable Case sensitivity on naming identifiers |
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2010-02-04 02:13:11 | Re: Add on_trusted_init and on_untrusted_init to plperl UPDATED [PATCH] |
Previous Message | Joe Conway | 2010-02-04 00:34:17 | proposed PQconnectdbParams macros (was Re: [BUGS] BUG #5304: psql using conninfo fails in connecting to the server) |