You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Over-aligned Vec<u8> can potentially be converted into Vec<u16> without violating the requirement of dealloc with the correct alignment by a layout-changing realloc
This would probably take the shape of unsafe fn grow(&self, ptr: *mut u8, old_layout: Layout, new_layout: Layout) -> *mut u8 { ... } and shrink for GlobalAlloc along with the plumbing to see that through. These should probably be defaulted to call realloc where possible to avoid pessimization of old GlobalAlloc implementers.
Alternatively to providing the grow/shrink split on GlobalAlloc, some alternative symbol to realloc could be used which still allows both grow and shrink. C-inspired bad idea: realloc_s 😛 but resize might be fine. realloc will still exist (maybe deprecated) to point at resize as the improved alternative.
The text was updated successfully, but these errors were encountered:
This is a short-term potentially stabilizable incremental improvement on the status quo.
Zulip discussion
There's at least two benefits to doing this:
realloc
that takesLayout
will allow it to benefit from Enforce that layout size fits in isize in Layout rust#95295Vec<u8>
can potentially be converted intoVec<u16>
without violating the requirement of dealloc with the correct alignment by a layout-changingrealloc
This would probably take the shape of
unsafe fn grow(&self, ptr: *mut u8, old_layout: Layout, new_layout: Layout) -> *mut u8 { ... }
andshrink
forGlobalAlloc
along with the plumbing to see that through. These should probably be defaulted to callrealloc
where possible to avoid pessimization of oldGlobalAlloc
implementers.Alternatively to providing the
grow
/shrink
split onGlobalAlloc
, some alternative symbol torealloc
could be used which still allows both grow and shrink. C-inspired bad idea:realloc_s
😛 butresize
might be fine.realloc
will still exist (maybe deprecated) to point atresize
as the improved alternative.The text was updated successfully, but these errors were encountered: