improve std/mem doc comments

This commit is contained in:
2026-08-11 22:36:22 +02:00
parent 101795c0b8
commit 4f142b72f2
+6 -1
View File
@@ -78,6 +78,7 @@ realloc proc($T type, allocator Allocator, memory []mut T, new_count usize) []mu
old_memory = ptrcast!(u8, memory.ptr)
old_size = memory.len * element_size
}
resized := raw_realloc(
allocator,
old_memory,
@@ -85,6 +86,7 @@ realloc proc($T type, allocator Allocator, memory []mut T, new_count usize) []mu
new_count * element_size,
alignof!(T),
)
if resized |bytes| {
pointer *mut T :: ptrcast!(T, bytes)
return pointer[..new_count]
@@ -105,7 +107,10 @@ free proc($T type, allocator Allocator, memory []T) void {
)
}
#! get an empty slice of type `T` with `count` elements.
#! create a slice backed by `empty_storage` without allocating.
#! precondition: `count` must be 0 or `sizeof!(T)` must be 0; otherwise the slice
#! exceeds its backing storage.
@hide:file
empty_slice proc($T type, count usize) []mut T {
pointer *mut T :: ptrcast!(T, (&empty_storage).ptr)
return pointer[..count]