On Mon, Jun 16, 2025 at 12:49 PM Alice Ryhl <alicer...@google.com> wrote:
>
> On Wed, Jun 11, 2025 at 9:48 PM Burak Emir <b...@google.com> wrote:
> > +impl core::ops::DerefMut for Bitmap {
> > +    fn deref_mut(&mut self) -> &mut CBitmap {
> > +        let ptr = if self.nbits <= bindings::BITS_PER_LONG as _ {
> > +            // SAFETY: Bitmap is represented inline.
> > +            unsafe { core::ptr::addr_of_mut!(self.repr.bitmap) }
> > +        } else {
> > +            // SAFETY: Bitmap is represented as array of `unsigned long`.
> > +            unsafe { self.repr.ptr.as_mut() }
>
> Nit: You want NonNull::as_mut_ptr() here.

Can you explain? That seems to be an unstable method that exists so
one can get pointer to slice buffer.

The repr.ptr case is NonNull<usize>, not a slice - though "morally",
it is actually an owned C array.
Are you suggesting we could/should represent it as a Rust one?
However, we'd like it to use the C API to free etc.

Thanks,
Burak

Reply via email to