Skip to main content

array_read_capacity

Function array_read_capacity 

Source
pub fn array_read_capacity(len: i32, remaining: usize) -> usize
Expand description

Initial Vec capacity for a decoded array.

The claimed element count comes off the wire, so it must never be trusted for allocation — a hostile or corrupt length of i32::MAX would otherwise reserve gigabytes up front and abort the process under panic = "abort". The claim is clamped by the bytes actually remaining in the buffer (every element costs at least one wire byte) and a fixed budget; arrays longer than the budget grow on demand as elements are actually decoded.