[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAH5fLgievsJOe7QET+Wh2c0upygv-nhSnOuTN8K_QkruLwOPgA@mail.gmail.com>
Date: Mon, 23 Sep 2024 15:56:28 +0200
From: Alice Ryhl <aliceryhl@...gle.com>
To: Danilo Krummrich <dakr@...nel.org>
Cc: ojeda@...nel.org, alex.gaynor@...il.com, wedsonaf@...il.com,
boqun.feng@...il.com, gary@...yguo.net, bjorn3_gh@...tonmail.com,
benno.lossin@...ton.me, a.hindborg@...sung.com, akpm@...ux-foundation.org,
daniel.almeida@...labora.com, faith.ekstrand@...labora.com,
boris.brezillon@...labora.com, lina@...hilina.net, mcanal@...lia.com,
zhiw@...dia.com, cjia@...dia.com, jhubbard@...dia.com, airlied@...hat.com,
ajanulgu@...hat.com, lyude@...hat.com, linux-kernel@...r.kernel.org,
rust-for-linux@...r.kernel.org, linux-mm@...ck.org
Subject: Re: [RFC PATCH] rust: alloc: pass `old_layout` to `Allocator`
On Sat, Sep 21, 2024 at 5:33 PM Danilo Krummrich <dakr@...nel.org> wrote:
> @@ -84,11 +92,18 @@ unsafe fn call(
> &self,
> ptr: Option<NonNull<u8>>,
> layout: Layout,
> + old_layout: Layout,
> flags: Flags,
> ) -> Result<NonNull<[u8]>, AllocError> {
> let size = aligned_size(layout);
> let ptr = match ptr {
> - Some(ptr) => ptr.as_ptr(),
> + Some(ptr) => {
> + if old_layout.size() == 0 {
> + ptr::null()
> + } else {
> + ptr.as_ptr()
> + }
> + }
This is making Allocator work with zero-sized types, which deviates
from std. We should not do that without a reason. What is the reason?
Alice
Powered by blists - more mailing lists