Re: proposed PQconnectdbParams macros (was Re: [BUGS] BUG #5304: psql using conninfo fails in connecting to the server)
В списке pgsql-hackers по дате отправления:
| От | Tom Lane |
|---|---|
| Тема | Re: proposed PQconnectdbParams macros (was Re: [BUGS] BUG #5304: psql using conninfo fails in connecting to the server) |
| Дата | |
| Msg-id | 22663.1265245829@sss.pgh.pa.us обсуждение |
| Ответ на | proposed PQconnectdbParams macros (was Re: [BUGS] BUG #5304: psql using conninfo fails in connecting to the server) (Joe Conway <mail@joeconway.com>) |
| Список | pgsql-hackers |
Joe Conway <mail@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
В списке pgsql-hackers по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера