Skip to content

Commit e630b20

Browse files
committed
std.mem.Allocator.VTable: improve doc comment wording
1 parent 1bb8b4a commit e630b20

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

lib/std/mem/Allocator.zig

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,20 @@ ptr: *anyopaque,
2020
vtable: *const VTable,
2121

2222
pub const VTable = struct {
23-
/// Allocate exactly `len` bytes aligned to `alignment`, or return `null`
24-
/// indicating the allocation failed.
23+
/// Return a pointer to `len` bytes with specified `alignment`, or return
24+
/// `null` indicating the allocation failed.
2525
///
2626
/// `ret_addr` is optionally provided as the first return address of the
2727
/// allocation call stack. If the value is `0` it means no return address
2828
/// has been provided.
29-
///
30-
/// The returned slice of memory must have been `@memset` to `undefined`
31-
/// by the allocator implementation.
3229
alloc: *const fn (*anyopaque, len: usize, alignment: Alignment, ret_addr: usize) ?[*]u8,
3330

3431
/// Attempt to expand or shrink memory in place.
3532
///
3633
/// `memory.len` must equal the length requested from the most recent
37-
/// successful call to `alloc` or `resize`. `alignment` must equal the same
38-
/// value that was passed as the `alignment` parameter to the original
39-
/// `alloc` call.
34+
/// successful call to `alloc`, `resize`, or `remap`. `alignment` must
35+
/// equal the same value that was passed as the `alignment` parameter to
36+
/// the original `alloc` call.
4037
///
4138
/// A result of `true` indicates the resize was successful and the
4239
/// allocation now has the same address but a size of `new_len`. `false`
@@ -53,9 +50,9 @@ pub const VTable = struct {
5350
/// Attempt to expand or shrink memory, allowing relocation.
5451
///
5552
/// `memory.len` must equal the length requested from the most recent
56-
/// successful call to `alloc` or `resize`. `alignment` must equal the same
57-
/// value that was passed as the `alignment` parameter to the original
58-
/// `alloc` call.
53+
/// successful call to `alloc`, `resize`, or `remap`. `alignment` must
54+
/// equal the same value that was passed as the `alignment` parameter to
55+
/// the original `alloc` call.
5956
///
6057
/// A non-`null` return value indicates the resize was successful. The
6158
/// allocation may have same address, or may have been relocated. In either
@@ -73,11 +70,10 @@ pub const VTable = struct {
7370

7471
/// Free and invalidate a region of memory.
7572
///
76-
/// `memory.len` must equal the most recent length returned by `alloc` or
77-
/// given to a successful `resize` call.
78-
///
79-
/// `alignment` must equal the same value that was passed as the
80-
/// `alignment` parameter to the original `alloc` call.
73+
/// `memory.len` must equal the length requested from the most recent
74+
/// successful call to `alloc`, `resize`, or `remap`. `alignment` must
75+
/// equal the same value that was passed as the `alignment` parameter to
76+
/// the original `alloc` call.
8177
///
8278
/// `ret_addr` is optionally provided as the first return address of the
8379
/// allocation call stack. If the value is `0` it means no return address

0 commit comments

Comments
 (0)