Re: [PATCH] rust: alloc: satisfy `aligned_alloc` requirements
From: Tamir Duberstein
Date: Sat Feb 01 2025 - 17:02:11 EST
On Sat, Feb 1, 2025 at 4:58 PM Danilo Krummrich <dakr@xxxxxxxxxx> wrote:
>
> On Sat, Feb 01, 2025 at 04:19:48PM -0500, Tamir Duberstein wrote:
> > Hi Danilo, thanks for the review!
> >
> > On Sat, Feb 1, 2025 at 3:18 PM Danilo Krummrich <dakr@xxxxxxxxxx> wrote:
> > >
> > > I think I prefer this to be slightly more compact:
> > >
> > > let min_align = core::mem::size_of::<*const crate::ffi::c_void>();
> > > let (align, size) = if layout.align() < min_align {
> > > (min_align, layout.size().div_ceil(min_align) * min_align)
> > > } else {
> > > (layout.align(), layout.size())
> > > };
> >
> > I was trying to avoid repeated calls to either function, but I'm happy
> > to shorten the variable names. Would that suit?
>
> I think calling layout.align() twice is fine, no need shadow align for that.
Sure. Anything else?