Skip to content

Pool and Allocator are difficult to use together #192

@pchickey

Description

@pchickey

ngx::core::Pool impls the allocator-api2 Allocator trait, which makes allocations with &self methods.

However, all of the allocations made through Pool's own impl methods take &mut self.

In practice, this means that if I have an ngx_pool_t pointer and I have one API that uses the pool via Allocator (e.g. NgxString::new_in) and another that uses Pool's impl methods directly (e.g. https://github.com/nginx/nginx-acme/blob/main/src/net/resolver.rs#L138), I have to construct two different Pools from the same raw pointer.

I don't think the Allocator impl is unsound, so I propose the best way to solve this is to downgrade all of Pool's impl methods from &mut self to &self.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions