fix(event_loop): fix some wrong allocs
This commit is contained in:
parent
29f4edc059
commit
f97de2fe83
5 changed files with 14 additions and 10 deletions
|
|
@ -25,7 +25,7 @@ event_loop *event_loop_init() {
|
|||
event_loop *el = calloc(sizeof(event_loop), 1);
|
||||
|
||||
// No idea if this is a good starter value
|
||||
el->connections = calloc(sizeof(event_loop_conn), 16);
|
||||
el->connections = calloc(sizeof(event_loop_conn *), 16);
|
||||
el->connection_count = 16;
|
||||
|
||||
return el;
|
||||
|
|
@ -34,7 +34,7 @@ event_loop *event_loop_init() {
|
|||
int event_loop_put(event_loop *el, event_loop_conn *conn) {
|
||||
if ((size_t)conn->fd >= el->connection_count) {
|
||||
event_loop_conn **resized =
|
||||
realloc(el->connections, sizeof(event_loop_conn) * (conn->fd + 1));
|
||||
realloc(el->connections, sizeof(event_loop_conn *) * (conn->fd + 1));
|
||||
|
||||
if (resized == NULL) {
|
||||
return -1;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "http_loop.h"
|
||||
#include "log.h"
|
||||
|
||||
// cppcheck-suppress syntaxError
|
||||
static const char *http_response_format = "HTTP/1.1 %i %s\n"
|
||||
"Server: lander/" LANDER_VERSION "\n"
|
||||
"Content-Length: %lu\n";
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ bool http_loop_step_body_to_buf(event_loop_conn *conn) {
|
|||
}
|
||||
|
||||
ctx->req.body.type = http_body_buf;
|
||||
ctx->req.body.buf = malloc(ctx->req.body.expected_len * sizeof(uint8_t));
|
||||
ctx->req.body.buf = malloc(ctx->req.body.expected_len * sizeof(char));
|
||||
ctx->req.body.len = 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue