Trait capnp::message::Allocator [−][src]
An object that allocates memory for a Cap’n Proto message as it is being built.
Required methods
fn allocate_segment(&mut self, minimum_size: u32) -> (*mut u8, u32)
[src]
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
at least 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
previous segment.
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)
[src]
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 allocate_segment()
.
Implementations on Foreign Types
impl<'a, A> Allocator for &'a mut A where
A: Allocator,
[src]
A: Allocator,