Skip to content

Commit 4aab533

Browse files
committed
allocator::win32::IMalloc: late doc clarifications in response to ZST fixes
1 parent 3b92348 commit 4aab533

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/allocator/win32/imalloc.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,19 @@ use core::ptr::{NonNull, null_mut};
1212

1313
/// [`IMalloc::Alloc`] / [`IMalloc::Realloc`] / [`IMalloc::Free`] / [`IMalloc::GetSize`]
1414
///
15+
/// Uses the [`IMalloc`](https://learn.microsoft.com/en-us/windows/win32/api/objidl/nn-objidl-imalloc) interface as used for COM (de)allocations.
16+
/// Consider using [`Heap`](super::Heap) directly instead, unless you're specifically doing COM / have documentation mandating a specific (de)allocator for interop purpouses.
17+
///
1518
/// | Rust | C++ |
1619
/// | ----------------------------------| ----------------------|
17-
/// | [`thin::Alloc::alloc_uninit`] | [`IMalloc::Alloc`]
18-
/// | [`thin::Realloc::realloc_uninit`] | [`IMalloc::Realloc`]
20+
/// | [`thin::Alloc::alloc_uninit`] | [`IMalloc::Alloc`] <sup>\[1\]</sup>
21+
/// | [`thin::Realloc::realloc_uninit`] | [`IMalloc::Realloc`] <sup>\[2\]</sup>
1922
/// | [`thin::Free::free`] | [`IMalloc::Free`]
20-
/// | [`thin::SizeOf::size_of`] | [`IMalloc::GetSize`]
23+
/// | [`thin::SizeOf::size_of`] | [`IMalloc::GetSize`] <sup>\[3\]</sup>
2124
///
22-
/// Uses the [`IMalloc`](https://learn.microsoft.com/en-us/windows/win32/api/objidl/nn-objidl-imalloc) interface as used for COM (de)allocations.
23-
/// Consider using [`Heap`](super::Heap) directly instead, unless you're specifically doing COM / have documentation mandating a specific (de)allocator for interop purpouses.
25+
/// 1. `size` / `layout` of 0 bytes will allocate successfully
26+
/// 2. `new_size` / `new_layout` will be rounded up to at least 1 byte, otherwise [`IMalloc::Realloc`] would free!
27+
/// 3. size will be inconsistent for "zero" sized allocations
2428
///
2529
/// ## References
2630
/// * [`CoTaskMem`](super::CoTaskMem) (stateless equivalent)

0 commit comments

Comments
 (0)