kore

Kore is a web application platform for writing scalable, concurrent web based processes in C or Python.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit 2b2e765fe60a2d25f677cf7df3668d4f10c5a0dd
parent a603b77e24dd6b8394e25e32941ccc4185080a22
Author: Joris Vink <joris@coders.se>
Date:   Sun, 12 Oct 2014 01:17:35 +0200

Allow 0 parameters for kore_pgsql_query_params()

Diffstat:
src/pgsql.c | 22++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/src/pgsql.c b/src/pgsql.c @@ -102,16 +102,22 @@ kore_pgsql_query_params(struct kore_pgsql *pgsql, struct http_request *req, if (!pgsql_prepare(pgsql, req, query)) return (KORE_RESULT_ERROR); - va_start(args, count); + if (count > 0) { + va_start(args, count); - lengths = kore_calloc(count, sizeof(int)); - formats = kore_calloc(count, sizeof(int)); - values = kore_calloc(count, sizeof(char *)); + lengths = kore_calloc(count, sizeof(int)); + formats = kore_calloc(count, sizeof(int)); + values = kore_calloc(count, sizeof(char *)); - for (i = 0; i < count; i++) { - values[i] = va_arg(args, void *); - lengths[i] = va_arg(args, u_int32_t); - formats[i] = va_arg(args, int); + for (i = 0; i < count; i++) { + values[i] = va_arg(args, void *); + lengths[i] = va_arg(args, u_int32_t); + formats[i] = va_arg(args, int); + } + } else { + lengths = NULL; + formats = NULL; + values = NULL; } if (!PQsendQueryParams(pgsql->conn->db, query, count, NULL,