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 2b97d371f5a3a6fae04dc3a81555b04f0b4c67f8
parent 2dfd22a79a7d8c04a43970b3f69c4d291d39b43a
Author: Joris Vink <joris@coders.se>
Date:   Tue,  7 Jun 2016 13:37:00 +0200

Merge pull request #127 from raphaelmonrouzeau/master

Added new function kore_pgsql_v_query_params().
Diffstat:
includes/pgsql.h | 2++
src/pgsql.c | 28++++++++++++++++++++--------
2 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/includes/pgsql.h b/includes/pgsql.h @@ -67,6 +67,8 @@ void kore_pgsql_continue(struct http_request *, struct kore_pgsql *); int kore_pgsql_query(struct kore_pgsql *, const char *); int kore_pgsql_query_params(struct kore_pgsql *, const char *, int, u_int8_t, ...); +int kore_pgsql_v_query_params(struct kore_pgsql *, + const char *, int, u_int8_t, va_list); int kore_pgsql_register(const char *, const char *); int kore_pgsql_ntuples(struct kore_pgsql *); void kore_pgsql_logerror(struct kore_pgsql *); diff --git a/src/pgsql.c b/src/pgsql.c @@ -150,11 +150,10 @@ kore_pgsql_query(struct kore_pgsql *pgsql, const char *query) } int -kore_pgsql_query_params(struct kore_pgsql *pgsql, - const char *query, int result, u_int8_t count, ...) +kore_pgsql_v_query_params(struct kore_pgsql *pgsql, + const char *query, int result, u_int8_t count, va_list args) { u_int8_t i; - va_list args; char **values; int *lengths, *formats, ret; @@ -164,8 +163,6 @@ kore_pgsql_query_params(struct kore_pgsql *pgsql, } 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 *)); @@ -208,9 +205,6 @@ kore_pgsql_query_params(struct kore_pgsql *pgsql, ret = KORE_RESULT_OK; cleanup: - if (count > 0) - va_end(args); - kore_mem_free(values); kore_mem_free(lengths); kore_mem_free(formats); @@ -219,6 +213,24 @@ cleanup: } int +kore_pgsql_query_params(struct kore_pgsql *pgsql, + const char *query, int result, u_int8_t count, ...) +{ + int ret; + va_list args; + + if (count > 0) + va_start(args, count); + + ret = kore_pgsql_v_query_params(pgsql, query, result, count, args); + + if (count > 0) + va_end(args); + + return (ret); +} + +int kore_pgsql_register(const char *dbname, const char *connstring) { struct pgsql_db *pgsqldb;