3 ms·
> The context parameter already addresses that need. How so? The context parameter identifies the allocator instance. What if the library needs to allocate obj
by el_pollo_diablo 3y ago
> The context parameter already addresses that need.
How so? The context parameter identifies the allocator instance. What if the library needs to allocate objects with different alignment requirements with the same allocator instance?
Alignment requirement is just like allocation size (*). It varies from call to call, and generic allocators need to deal with heterogeneous alignments and sizes.
(*) Case in point: Rust's Allocator interface (https://doc.rust-lang.org/std/alloc/trait.Allocator.html https://doc.rust-lang.org/std/alloc/trait.Allocator.html) bundles them up in a single Layout object.