From 43fec8678e80d6ce61432849a703567b3994e904 Mon Sep 17 00:00:00 2001 From: Joris Vink Date: Thu, 14 Jul 2016 12:34:29 +0200 Subject: [PATCH] kore_buf_create -> kore_buf_alloc. --- examples/generic/src/example.c | 6 +++--- examples/integers/src/check_integers.c | 2 +- examples/json_yajl/src/json_yajl.c | 2 +- examples/parameters/src/parameters.c | 2 +- examples/tasks/src/tasks.c | 2 +- src/cli.c | 12 ++++++------ src/http.c | 12 ++++++------ src/utils.c | 4 ++-- src/websocket.c | 6 +++--- 9 files changed, 24 insertions(+), 24 deletions(-) diff --git a/examples/generic/src/example.c b/examples/generic/src/example.c index a794b46..63be9f2 100644 --- a/examples/generic/src/example.c +++ b/examples/generic/src/example.c @@ -122,7 +122,7 @@ serve_b64test(struct http_request *req) struct kore_buf *res; u_int8_t *data; - res = kore_buf_create(1024); + res = kore_buf_alloc(1024); for (i = 0; b64tests[i] != NULL; i++) test_base64((u_int8_t *)b64tests[i], strlen(b64tests[i]), res); @@ -144,7 +144,7 @@ serve_file_upload(struct http_request *req) size_t len; char *name, buf[BUFSIZ]; - b = kore_buf_create(asset_len_upload_html); + b = kore_buf_alloc(asset_len_upload_html); kore_buf_append(b, asset_upload_html, asset_len_upload_html); if (req->method == HTTP_METHOD_POST) { @@ -247,7 +247,7 @@ serve_params_test(struct http_request *req) else if (req->method == HTTP_METHOD_POST) http_populate_post(req); - b = kore_buf_create(asset_len_params_html); + b = kore_buf_alloc(asset_len_params_html); kore_buf_append(b, asset_params_html, asset_len_params_html); /* diff --git a/examples/integers/src/check_integers.c b/examples/integers/src/check_integers.c index 3605771..b2934e6 100755 --- a/examples/integers/src/check_integers.c +++ b/examples/integers/src/check_integers.c @@ -17,7 +17,7 @@ page(struct http_request *req) u_int8_t c, *data; http_populate_get(req); - buf = kore_buf_create(128); + buf = kore_buf_alloc(128); if (http_argument_get_byte(req, "id", &c)) kore_buf_appendf(buf, "byte\t%c\n", c); diff --git a/examples/json_yajl/src/json_yajl.c b/examples/json_yajl/src/json_yajl.c index 7606ac4..81bb1bc 100755 --- a/examples/json_yajl/src/json_yajl.c +++ b/examples/json_yajl/src/json_yajl.c @@ -43,7 +43,7 @@ page(struct http_request *req) /* * Read the entire received body into a memory buffer. */ - buf = kore_buf_create(128); + buf = kore_buf_alloc(128); for (;;) { ret = http_body_read(req, data, sizeof(data)); if (ret == -1) { diff --git a/examples/parameters/src/parameters.c b/examples/parameters/src/parameters.c index 33a6da8..f1f8aa9 100755 --- a/examples/parameters/src/parameters.c +++ b/examples/parameters/src/parameters.c @@ -56,7 +56,7 @@ page(struct http_request *req) * and Kore will return an error when trying to read it as such. */ - buf = kore_buf_create(128); + buf = kore_buf_alloc(128); /* Grab it as a string, we shouldn't free the result in sid. */ if (http_argument_get_string(req, "id", &sid)) diff --git a/examples/tasks/src/tasks.c b/examples/tasks/src/tasks.c index d1ea8fa..9b9dea7 100644 --- a/examples/tasks/src/tasks.c +++ b/examples/tasks/src/tasks.c @@ -193,7 +193,7 @@ run_curl(struct kore_task *t) if ((curl = curl_easy_init()) == NULL) return (KORE_RESULT_ERROR); - b = kore_buf_create(128); + b = kore_buf_alloc(128); /* Do CURL magic. */ curl_easy_setopt(curl, CURLOPT_POST, 1); diff --git a/src/cli.c b/src/cli.c index 6907967..669b678 100644 --- a/src/cli.c +++ b/src/cli.c @@ -1381,7 +1381,7 @@ cli_buildopt_cflags(struct buildopt *bopt, const char *string) bopt = cli_buildopt_default(); if (bopt->cflags == NULL) - bopt->cflags = kore_buf_create(128); + bopt->cflags = kore_buf_alloc(128); kore_buf_appendf(bopt->cflags, "%s ", string); } @@ -1393,7 +1393,7 @@ cli_buildopt_cxxflags(struct buildopt *bopt, const char *string) bopt = cli_buildopt_default(); if (bopt->cxxflags == NULL) - bopt->cxxflags = kore_buf_create(128); + bopt->cxxflags = kore_buf_alloc(128); kore_buf_appendf(bopt->cxxflags, "%s ", string); } @@ -1405,7 +1405,7 @@ cli_buildopt_ldflags(struct buildopt *bopt, const char *string) bopt = cli_buildopt_default(); if (bopt->ldflags == NULL) - bopt->ldflags = kore_buf_create(128); + bopt->ldflags = kore_buf_alloc(128); kore_buf_appendf(bopt->ldflags, "%s ", string); } @@ -1488,7 +1488,7 @@ cli_build_cflags(struct buildopt *bopt) cli_fatal("no such build flavor: %s", flavor); if (bopt->cflags == NULL) - bopt->cflags = kore_buf_create(128); + bopt->cflags = kore_buf_alloc(128); cli_build_flags_common(bopt->cflags); @@ -1515,7 +1515,7 @@ cli_build_cxxflags(struct buildopt *bopt) cli_fatal("no such build flavor: %s", flavor); if (bopt->cxxflags == NULL) - bopt->cxxflags = kore_buf_create(128); + bopt->cxxflags = kore_buf_alloc(128); cli_build_flags_common(bopt->cxxflags); @@ -1540,7 +1540,7 @@ cli_build_ldflags(struct buildopt *bopt) cli_fatal("no such build flavor: %s", flavor); if (bopt->ldflags == NULL) - bopt->ldflags = kore_buf_create(128); + bopt->ldflags = kore_buf_alloc(128); if (bopt->single_binary == 0) { #if defined(__MACH__) diff --git a/src/http.c b/src/http.c index f99fb5d..8d29dbb 100644 --- a/src/http.c +++ b/src/http.c @@ -79,7 +79,7 @@ http_init(void) TAILQ_INIT(&http_requests); TAILQ_INIT(&http_requests_sleeping); - header_buf = kore_buf_create(1024); + header_buf = kore_buf_alloc(1024); l = snprintf(http_version, sizeof(http_version), "server: kore (%d.%d.%d-%s)\r\n", KORE_VERSION_MAJOR, @@ -702,7 +702,7 @@ http_header_recv(struct netbuf *nb) } } else { req->http_body_fd = -1; - req->http_body = kore_buf_create(req->content_length); + req->http_body = kore_buf_alloc(req->content_length); kore_buf_append(req->http_body, end_headers, (nb->s_off - len)); } @@ -917,7 +917,7 @@ http_populate_post(struct http_request *req) req->http_body->offset = req->content_length; string = kore_buf_stringify(req->http_body, NULL); } else { - body = kore_buf_create(128); + body = kore_buf_alloc(128); for (;;) { ret = http_body_read(req, data, sizeof(data)); if (ret == -1) @@ -990,8 +990,8 @@ http_populate_multipart_form(struct http_request *req) if (blen == -1 || (size_t)blen >= sizeof(boundary)) return; - in = kore_buf_create(128); - out = kore_buf_create(128); + in = kore_buf_alloc(128); + out = kore_buf_alloc(128); if (!multipart_find_data(in, NULL, NULL, req, boundary, blen)) goto cleanup; @@ -1239,7 +1239,7 @@ multipart_add_field(struct http_request *req, struct kore_buf *in, struct kore_buf *data; char *string; - data = kore_buf_create(128); + data = kore_buf_alloc(128); if (!multipart_find_data(in, data, NULL, req, boundary, blen)) { kore_buf_free(data); diff --git a/src/utils.c b/src/utils.c index 33e395d..91fb7bb 100644 --- a/src/utils.c +++ b/src/utils.c @@ -400,7 +400,7 @@ kore_base64_encode(u_int8_t *data, size_t len, char **out) pdata = data; } - res = kore_buf_create(plen); + res = kore_buf_alloc(plen); i = 2; b = 0; @@ -456,7 +456,7 @@ kore_base64_decode(char *in, u_int8_t **out, size_t *olen) d = 0; c = 0; len = strlen(in); - res = kore_buf_create(len); + res = kore_buf_alloc(len); for (idx = 0; idx < len; idx++) { c = in[idx]; diff --git a/src/websocket.c b/src/websocket.c index 9d44fd0..0c450fe 100644 --- a/src/websocket.c +++ b/src/websocket.c @@ -73,7 +73,7 @@ kore_websocket_handshake(struct http_request *req, struct kore_wscbs *wscbs) return; } - buf = kore_buf_create(128); + buf = kore_buf_alloc(128); kore_buf_appendf(buf, "%s%s", key, WEBSOCKET_SERVER_RESPONSE); (void)SHA1_Init(&sctx); @@ -116,7 +116,7 @@ kore_websocket_send(struct connection *c, u_int8_t op, const void *data, { struct kore_buf *frame; - frame = kore_buf_create(len); + frame = kore_buf_alloc(len); websocket_frame_build(frame, op, data, len); net_send_queue(c, frame->data, frame->offset); kore_buf_free(frame); @@ -129,7 +129,7 @@ kore_websocket_broadcast(struct connection *src, u_int8_t op, const void *data, struct connection *c; struct kore_buf *frame; - frame = kore_buf_create(len); + frame = kore_buf_alloc(len); websocket_frame_build(frame, op, data, len); TAILQ_FOREACH(c, &connections, list) {