forked from cory/tildefriends
Prefer tf_resize_vec many places over tf_realloc.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4805 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
@ -256,7 +256,7 @@ static void _http_add_body_bytes(tf_http_connection_t* connection, const void* d
|
||||
{
|
||||
if (size)
|
||||
{
|
||||
connection->body = tf_realloc(connection->body, connection->body_length + size);
|
||||
connection->body = tf_resize_vec(connection->body, connection->body_length + size);
|
||||
memcpy((char*)connection->body + connection->body_length, data, size);
|
||||
connection->body_length += size;
|
||||
}
|
||||
@ -314,7 +314,7 @@ static void _http_add_body_bytes(tf_http_connection_t* connection, const void* d
|
||||
|
||||
if (!fin || connection->fragment_length)
|
||||
{
|
||||
connection->fragment = tf_realloc(connection->fragment, connection->fragment_length + length);
|
||||
connection->fragment = tf_resize_vec(connection->fragment, connection->fragment_length + length);
|
||||
memcpy((uint8_t*)connection->fragment + connection->fragment_length, message, length);
|
||||
connection->fragment_length += length;
|
||||
}
|
||||
@ -604,7 +604,7 @@ static void _http_on_connection(uv_stream_t* stream, int status)
|
||||
_http_tls_update(connection);
|
||||
}
|
||||
|
||||
http->connections = tf_realloc(http->connections, sizeof(tf_http_connection_t*) * (http->connections_count + 1));
|
||||
http->connections = tf_resize_vec(http->connections, sizeof(tf_http_connection_t*) * (http->connections_count + 1));
|
||||
http->connections[http->connections_count++] = connection;
|
||||
}
|
||||
|
||||
@ -668,7 +668,7 @@ int tf_http_listen(tf_http_t* http, int port, tf_tls_context_t* tls, tf_http_cle
|
||||
|
||||
void tf_http_add_handler(tf_http_t* http, const char* pattern, tf_http_callback_t* callback, tf_http_cleanup_t* cleanup, void* user_data)
|
||||
{
|
||||
http->handlers = tf_realloc(http->handlers, sizeof(tf_http_handler_t) * (http->handlers_count + 1));
|
||||
http->handlers = tf_resize_vec(http->handlers, sizeof(tf_http_handler_t) * (http->handlers_count + 1));
|
||||
http->handlers[http->handlers_count++] = (tf_http_handler_t)
|
||||
{
|
||||
.pattern = tf_strdup(pattern),
|
||||
|
Reference in New Issue
Block a user