3 ms·
The context parameter already addresses that need.
by gpvos 3y ago
The context parameter already addresses that need.
- 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.
- flohofwoe 3y agoNot really I think, the context pointer (I would call it "user data" though since that's more common in the C world) is normally passed around as an opaque pointer which is used by the allocator functions to find their own state, but not for passing additional parameters to the allocator.
- gpvos 3y agoI guess you're right. The alignment parameter may be different per allocation, not per arena/context.