diff --git a/src/http.c b/src/http.c index 8618f01a..95842be3 100644 --- a/src/http.c +++ b/src/http.c @@ -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), diff --git a/src/httpd.js.c b/src/httpd.js.c index 8f6536ec..f00774c8 100644 --- a/src/httpd.js.c +++ b/src/httpd.js.c @@ -456,7 +456,7 @@ static void _httpd_endpoint_mem(tf_http_request_t* request) { const char* stack = tf_util_backtrace_to_string(alloc[i].frames, alloc[i].frames_count); int line = snprintf(NULL, 0, "%zd bytes in %d allocations\n%s\n\n", alloc[i].size, alloc[i].count, stack); - response = tf_realloc(response, length + line); + response = tf_resize_vec(response, length + line); snprintf(response + length, line, "%zd bytes in %d allocations\n%s\n\n", alloc[i].size, alloc[i].count, stack); length += line - 1; tf_free((void*)stack); diff --git a/src/serialize.c b/src/serialize.c index 54e189f6..553a345e 100644 --- a/src/serialize.c +++ b/src/serialize.c @@ -57,7 +57,7 @@ void tf_serialize_store(tf_task_t* task, tf_taskstub_t* to, void** out_buffer, s tf_trace_begin(trace, "tf_serialize_store"); buffer_t tmp = { 0 }; _serialize_store(task, to, &tmp, value); - tmp.data = tf_realloc(tmp.data, tmp.size); + tmp.data = tf_resize_vec(tmp.data, tmp.size); *out_buffer = tmp.data; *out_size = tmp.size; tf_trace_end(trace); diff --git a/src/socket.js.c b/src/socket.js.c index 5bf6d577..be934fdf 100644 --- a/src/socket.js.c +++ b/src/socket.js.c @@ -168,7 +168,7 @@ socket_t* _socket_create_internal(JSContext* context) { socket_t* socket = tf_malloc(sizeof(socket_t)); memset(socket, 0, sizeof(*socket)); - _sockets = tf_realloc(_sockets, sizeof(socket_t*) * (_sockets_count + 1)); + _sockets = tf_resize_vec(_sockets, sizeof(socket_t*) * (_sockets_count + 1)); _sockets[_sockets_count++] = socket; socket->_closePromise = -1; @@ -263,7 +263,7 @@ void _socket_close_internal(socket_t* socket) { _sockets[i] = _sockets[_sockets_count - 1]; --_sockets_count; - _sockets = tf_realloc(_sockets, sizeof(socket_t*) * _sockets_count); + _sockets = tf_resize_vec(_sockets, sizeof(socket_t*) * _sockets_count); break; } } diff --git a/src/ssb.db.c b/src/ssb.db.c index 0dde7f25..9ac3bab5 100644 --- a/src/ssb.db.c +++ b/src/ssb.db.c @@ -354,7 +354,7 @@ static char* _tf_ssb_db_get_message_blob_wants(tf_ssb_t* ssb, int64_t rowid) { int id_size = sqlite3_column_bytes(statement, 0); const uint8_t* id = sqlite3_column_text(statement, 0); - result = tf_realloc(result, size + id_size + 1); + result = tf_resize_vec(result, size + id_size + 1); memcpy(result + size, id, id_size + 1); size += id_size + 1; }