authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2023-07-12 16:49:10-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-07-12 21:54:30-07:00
log2896266a038cde4b64743534df7ccdd3f5b9347f
treeae02c48c6c7ba3fbbdcca9c09518ca930b57fc4a
parente05c242cd89d03ae67fa7b8d5fc33fb5dc42dbe3

docs: Fix outdated doc comments about allocating 'at least' the requested size

The 'at least' behavior of the Allocator interface was removed in #13666, so anything that used reallocAtLeast or the .at_least Exact behavior could still have doc comments that reference no-longer-true behavior. Funnily enough, ArrayList is the only place that used this functionality (outside of allocator test cases), so its doc comments are the only things that need to be fixed. This was checked by resetting to deda6b514691c3a7ffc7931469886d0e7be2f67e and searching for all instances of `reallocAtLeast` and `.at_least` (one of which would need to be used to get the `.at_least` behavior)

1 files changed, 10 insertions(+), 10 deletions(-)

lib/std/array_list.zig+10-10
...@@ -60,8 +60,8 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type {...@@ -60,8 +60,8 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type {
60 };60 };
61 }61 }
6262
63 /// Initialize with capacity to hold at least `num` elements.63 /// Initialize with capacity to hold `num` elements.
64 /// The resulting capacity is likely to be equal to `num`.64 /// The resulting capacity will equal `num` exactly.
65 /// Deinitialize with `deinit` or use `toOwnedSlice`.65 /// Deinitialize with `deinit` or use `toOwnedSlice`.
66 pub fn initCapacity(allocator: Allocator, num: usize) Allocator.Error!Self {66 pub fn initCapacity(allocator: Allocator, num: usize) Allocator.Error!Self {
67 var self = Self.init(allocator);67 var self = Self.init(allocator);
...@@ -379,9 +379,9 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type {...@@ -379,9 +379,9 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type {
379 return self.ensureTotalCapacityPrecise(better_capacity);379 return self.ensureTotalCapacityPrecise(better_capacity);
380 }380 }
381381
382 /// Modify the array so that it can hold at least `new_capacity` items.382 /// Modify the array so that it can hold `new_capacity` items.
383 /// Like `ensureTotalCapacity`, but the resulting capacity is much more likely383 /// Like `ensureTotalCapacity`, but the resulting capacity is guaranteed
384 /// (but not guaranteed) to be equal to `new_capacity`.384 /// to be equal to `new_capacity`.
385 /// Invalidates pointers if additional memory is needed.385 /// Invalidates pointers if additional memory is needed.
386 pub fn ensureTotalCapacityPrecise(self: *Self, new_capacity: usize) Allocator.Error!void {386 pub fn ensureTotalCapacityPrecise(self: *Self, new_capacity: usize) Allocator.Error!void {
387 if (@sizeOf(T) == 0) {387 if (@sizeOf(T) == 0) {
...@@ -570,8 +570,8 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ...@@ -570,8 +570,8 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ
570 return if (alignment) |a| ([:s]align(a) T) else [:s]T;570 return if (alignment) |a| ([:s]align(a) T) else [:s]T;
571 }571 }
572572
573 /// Initialize with capacity to hold at least num elements.573 /// Initialize with capacity to hold `num` elements.
574 /// The resulting capacity is likely to be equal to `num`.574 /// The resulting capacity will equal `num` exactly.
575 /// Deinitialize with `deinit` or use `toOwnedSlice`.575 /// Deinitialize with `deinit` or use `toOwnedSlice`.
576 pub fn initCapacity(allocator: Allocator, num: usize) Allocator.Error!Self {576 pub fn initCapacity(allocator: Allocator, num: usize) Allocator.Error!Self {
577 var self = Self{};577 var self = Self{};
...@@ -885,9 +885,9 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ...@@ -885,9 +885,9 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ
885 return self.ensureTotalCapacityPrecise(allocator, better_capacity);885 return self.ensureTotalCapacityPrecise(allocator, better_capacity);
886 }886 }
887887
888 /// Modify the array so that it can hold at least `new_capacity` items.888 /// Modify the array so that it can hold `new_capacity` items.
889 /// Like `ensureTotalCapacity`, but the resulting capacity is much more likely889 /// Like `ensureTotalCapacity`, but the resulting capacity is guaranteed
890 /// (but not guaranteed) to be equal to `new_capacity`.890 /// to be equal to `new_capacity`.
891 /// Invalidates pointers if additional memory is needed.891 /// Invalidates pointers if additional memory is needed.
892 pub fn ensureTotalCapacityPrecise(self: *Self, allocator: Allocator, new_capacity: usize) Allocator.Error!void {892 pub fn ensureTotalCapacityPrecise(self: *Self, allocator: Allocator, new_capacity: usize) Allocator.Error!void {
893 if (@sizeOf(T) == 0) {893 if (@sizeOf(T) == 0) {