Il mar 12 ago 2025, 17:17 Zhao Liu <zhao1....@intel.com> ha scritto: > But look closer to Opaque<>, it has 2 safe methods: as_mut_ptr() & > raw_get(). > > These 2 methods indicate that the T pointed by Qpaque<T> is mutable, > which has the conflict with the original `*const > bindings::MemoryRegionSection`. > > So from this point, it seems unsafe to use Qpaque<> on this case. >
Yes, it's similar to NonNull<>. I am not sure that you need Opaque<> here; since the pointer is const, maybe you can just dereference it to a &bindings::MemoryRegionSection. Is it useful to have the Opaque<> wrapper here? To address this, I think we need: > - rich comments about this MemoryRegionSection is actually immuatble. > - modify other C functions to accept `const *MemoryRegionSection` as > argument. > Yes, adding const is useful in this case. Paolo What do you think? > > Thanks, > Zhao > >