kore_buf_create -> kore_buf_alloc.

This commit is contained in:
Joris Vink 2016-07-14 12:34:29 +02:00
parent b28b60c2ff
commit 43fec8678e
9 changed files with 24 additions and 24 deletions

View File

@ -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);
/*

View File

@ -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);

View File

@ -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) {

View File

@ -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))

View File

@ -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);

View File

@ -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__)

View File

@ -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);

View File

@ -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];

View File

@ -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) {