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,
2020vtable: *const VTable,
2121
2222pub 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