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
/// Uses the default COM / "OLE task memory" allocator provided by [`CoGetMalloc`], which in turn simply uses [`Heap*`](super::Heap) functions under the hood.
14
+
/// Consider using [`Heap`](super::Heap) directly instead, unless you're specifically doing COM / have documentation mandating a specific (de)allocator for interop purpouses.
/// Uses the default COM / "OLE task memory" allocator provided by [`CoGetMalloc`], which in turn simply uses [`Heap*`](super::Heap) functions under the hood.
20
-
/// Consider using [`Heap`](super::Heap) directly instead, unless you're specifically doing COM / have documentation mandating a specific (de)allocator for interop purpouses.
22
+
/// 1. `size` / `layout` of 0 bytes will allocate successfully
23
+
/// 2. `new_size` / `new_layout` will be rounded up to at least 1 byte, otherwise [`CoTaskMemRealloc`] would free!
// SAFETY: ✔️ `ptr` belongs to `self` per [`thin::Realloc::realloc_uninit`]'s documented safety preconditions, and thus was allocated with CoTaskMem{Alloc,Realloc}
93
-
let alloc = unsafe{CoTaskMemRealloc(ptr.as_ptr().cast(), new_size)};
101
+
let alloc = unsafe{CoTaskMemRealloc(ptr.as_ptr().cast(), new_size.max(1))};
94
102
NonNull::new(alloc.cast()).ok_or(())
95
103
}
96
104
@@ -133,11 +141,15 @@ unsafe impl thin::Free for CoTaskMem {
0 commit comments