You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For better integration with Rust, the C code was modified to allocate some vectors (search for the vec! macro in lib.rs). There's probably a better way to do this, avoiding the allocations.
The text was updated successfully, but these errors were encountered:
Allocations were removed using some slice trickery. Given that we know the max size, we can allocate a slice array on the stack instead of using a vector.
for i in0..((*host).buffer_count).wrapping_sub(1){
let buffer = ((*host).buffers).as_mut_ptr().add(1 + i);
in_buffers[i] = super::from_raw_parts_or_empty(
(*buffer).data,
(*buffer).data_length,
);
}
The send and peer allocations still exist. The peer one exists in ENet, so that's fine. It was changed to at least reserve the peer count ahead of time before pushing the peers.
The send allocation is worth keeping since most socket implementations will likely want to do this, anyway. It was changed to reserve the buffer count in 6fe949c. It could avoid this allocation if compression is disabled, but one allocation during send seems pretty harmless.
For better integration with Rust, the C code was modified to allocate some vectors (search for the
vec!
macro inlib.rs
). There's probably a better way to do this, avoiding the allocations.The text was updated successfully, but these errors were encountered: