authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-02-06 14:50:20-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-02-06 14:50:20-08:00
loge630b20c6228aa3c8b50841af5ce7bc102202162
tree0301180c1c342c92d6d9465a8a2eed240e3154e3
parent1bb8b4ad61659da8b4f53faf959bfdc8415bf41e

std.mem.Allocator.VTable: improve doc comment wording


1 files changed, 12 insertions(+), 16 deletions(-)

lib/std/mem/Allocator.zig+12-16
...@@ -20,23 +20,20 @@ ptr: *anyopaque,...@@ -20,23 +20,20 @@ ptr: *anyopaque,
20vtable: *const VTable,20vtable: *const VTable,
2121
22pub const VTable = struct {22pub const VTable = struct {
23 /// Allocate exactly `len` bytes aligned to `alignment`, or return `null`23 /// Return a pointer to `len` bytes with specified `alignment`, or return
24 /// indicating the allocation failed.24 /// `null` indicating the allocation failed.
25 ///25 ///
26 /// `ret_addr` is optionally provided as the first return address of the26 /// `ret_addr` is optionally provided as the first return address of the
27 /// allocation call stack. If the value is `0` it means no return address27 /// allocation call stack. If the value is `0` it means no return address
28 /// has been provided.28 /// has been provided.
29 ///
30 /// The returned slice of memory must have been `@memset` to `undefined`
31 /// by the allocator implementation.
32 alloc: *const fn (*anyopaque, len: usize, alignment: Alignment, ret_addr: usize) ?[*]u8,29 alloc: *const fn (*anyopaque, len: usize, alignment: Alignment, ret_addr: usize) ?[*]u8,
3330
34 /// Attempt to expand or shrink memory in place.31 /// Attempt to expand or shrink memory in place.
35 ///32 ///
36 /// `memory.len` must equal the length requested from the most recent33 /// `memory.len` must equal the length requested from the most recent
37 /// successful call to `alloc` or `resize`. `alignment` must equal the same34 /// successful call to `alloc`, `resize`, or `remap`. `alignment` must
38 /// value that was passed as the `alignment` parameter to the original35 /// equal the same value that was passed as the `alignment` parameter to
39 /// `alloc` call.36 /// the original `alloc` call.
40 ///37 ///
41 /// A result of `true` indicates the resize was successful and the38 /// A result of `true` indicates the resize was successful and the
42 /// allocation now has the same address but a size of `new_len`. `false`39 /// allocation now has the same address but a size of `new_len`. `false`
...@@ -53,9 +50,9 @@ pub const VTable = struct {...@@ -53,9 +50,9 @@ pub const VTable = struct {
53 /// Attempt to expand or shrink memory, allowing relocation.50 /// Attempt to expand or shrink memory, allowing relocation.
54 ///51 ///
55 /// `memory.len` must equal the length requested from the most recent52 /// `memory.len` must equal the length requested from the most recent
56 /// successful call to `alloc` or `resize`. `alignment` must equal the same53 /// successful call to `alloc`, `resize`, or `remap`. `alignment` must
57 /// value that was passed as the `alignment` parameter to the original54 /// equal the same value that was passed as the `alignment` parameter to
58 /// `alloc` call.55 /// the original `alloc` call.
59 ///56 ///
60 /// A non-`null` return value indicates the resize was successful. The57 /// A non-`null` return value indicates the resize was successful. The
61 /// allocation may have same address, or may have been relocated. In either58 /// allocation may have same address, or may have been relocated. In either
...@@ -73,11 +70,10 @@ pub const VTable = struct {...@@ -73,11 +70,10 @@ pub const VTable = struct {
7370
74 /// Free and invalidate a region of memory.71 /// Free and invalidate a region of memory.
75 ///72 ///
76 /// `memory.len` must equal the most recent length returned by `alloc` or73 /// `memory.len` must equal the length requested from the most recent
77 /// given to a successful `resize` call.74 /// successful call to `alloc`, `resize`, or `remap`. `alignment` must
78 ///75 /// equal the same value that was passed as the `alignment` parameter to
79 /// `alignment` must equal the same value that was passed as the76 /// the original `alloc` call.
80 /// `alignment` parameter to the original `alloc` call.
81 ///77 ///
82 /// `ret_addr` is optionally provided as the first return address of the78 /// `ret_addr` is optionally provided as the first return address of the
83 /// allocation call stack. If the value is `0` it means no return address79 /// allocation call stack. If the value is `0` it means no return address