An object that allocates memory for a Cap'n Proto message as it is being built.
Allocates zeroed memory for a new segment, returning a pointer to the start of the segment
and a u32 indicating the length of the segment in words. The allocated segment must be
minimum_size words long (
minimum_size * 8 bytes long). Allocator implementations
commonly allocate much more than the minimum, to reduce the total number of segments needed.
A reasonable strategy is to allocate the maximum of
minimum_size and twice the size of the
UNSAFETY ALERT: Implementors must ensure all of the following: 1. the returned memory is initialized to all zeroes, 2. the returned memory is valid until deallocate_segment() is called on it, 3. the memory doesn't overlap with other allocated memory, 4. the memory is 8-byte aligned (or the "unaligned" feature is enabled for the capnp crate).
fn deallocate_segment(&mut self, ptr: *mut u8, word_size: u32, words_used: u32)
Indicates that a segment, previously allocated via allocate_segment(), is no longer in use.
word_size is the length of the segment in words, as returned from
words_used is always less than or equal to
word_size, and indicates how many
words (contiguous from the start of the segment) were possibly written with non-zero values.
Implementations on Foreign Types
impl<'a, A> Allocator for &'a mut A where[src]