diff options
author | José Bollo <jose.bollo@iot.bzh> | 2016-05-04 18:35:55 +0200 |
---|---|---|
committer | José Bollo <jose.bollo@iot.bzh> | 2016-05-04 18:35:55 +0200 |
commit | 6b9b3b16ac738f99bddde3d7d375f9986bb1c09a (patch) | |
tree | aaf4e66adfb1d19edc5f648aaa963cede8329b06 /src/afb-hreq.c | |
parent | 82adb27966eace72f810716c19c660efd7c8b15a (diff) |
try to avoid unnecessary copy
Change-Id: I98cd69133ba3babb2719fad8c7e31c4dcaf1ae97
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afb-hreq.c')
-rw-r--r-- | src/afb-hreq.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/afb-hreq.c b/src/afb-hreq.c index 6b7d64be..cc12da59 100644 --- a/src/afb-hreq.c +++ b/src/afb-hreq.c @@ -68,7 +68,7 @@ static struct afb_arg req_get(struct afb_hreq *hreq, const char *name); static void req_fail(struct afb_hreq *hreq, const char *status, const char *info); static void req_success(struct afb_hreq *hreq, json_object *obj, const char *info); static const char *req_raw(struct afb_hreq *hreq, size_t *size); -static void req_send(struct afb_hreq *hreq, char *buffer, size_t size); +static void req_send(struct afb_hreq *hreq, const char *buffer, size_t size); static int req_session_create(struct afb_hreq *hreq); static int req_session_check(struct afb_hreq *hreq, int refresh); static void req_session_close(struct afb_hreq *hreq); @@ -194,19 +194,19 @@ void afb_hreq_reply_empty(struct afb_hreq *hreq, unsigned status, ...) va_end(args); } -void afb_hreq_reply_static(struct afb_hreq *hreq, unsigned status, size_t size, char *buffer, ...) +void afb_hreq_reply_static(struct afb_hreq *hreq, unsigned status, size_t size, const char *buffer, ...) { va_list args; va_start(args, buffer); - afb_hreq_reply_v(hreq, status, MHD_create_response_from_buffer((unsigned)size, buffer, MHD_RESPMEM_PERSISTENT), args); + afb_hreq_reply_v(hreq, status, MHD_create_response_from_buffer((unsigned)size, (char*)buffer, MHD_RESPMEM_PERSISTENT), args); va_end(args); } -void afb_hreq_reply_copy(struct afb_hreq *hreq, unsigned status, size_t size, char *buffer, ...) +void afb_hreq_reply_copy(struct afb_hreq *hreq, unsigned status, size_t size, const char *buffer, ...) { va_list args; va_start(args, buffer); - afb_hreq_reply_v(hreq, status, MHD_create_response_from_buffer((unsigned)size, buffer, MHD_RESPMEM_MUST_COPY), args); + afb_hreq_reply_v(hreq, status, MHD_create_response_from_buffer((unsigned)size, (char*)buffer, MHD_RESPMEM_MUST_COPY), args); va_end(args); } @@ -661,7 +661,7 @@ static const char *req_raw(struct afb_hreq *hreq, size_t *size) return result; } -static void req_send(struct afb_hreq *hreq, char *buffer, size_t size) +static void req_send(struct afb_hreq *hreq, const char *buffer, size_t size) { afb_hreq_reply_free(hreq, MHD_HTTP_OK, size, buffer, NULL); } |