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)
This commit is contained in:
Ryan Liptak 2023-07-12 16:49:10 -07:00 committed by Andrew Kelley
parent e05c242cd8
commit 2896266a03

View File

@ -60,8 +60,8 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type {
}; };
} }
/// Initialize with capacity to hold at least `num` elements. /// Initialize with capacity to hold `num` elements.
/// The resulting capacity is likely to be equal to `num`. /// The resulting capacity will equal `num` exactly.
/// Deinitialize with `deinit` or use `toOwnedSlice`. /// Deinitialize with `deinit` or use `toOwnedSlice`.
pub fn initCapacity(allocator: Allocator, num: usize) Allocator.Error!Self { pub fn initCapacity(allocator: Allocator, num: usize) Allocator.Error!Self {
var self = Self.init(allocator); var self = Self.init(allocator);
@ -379,9 +379,9 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type {
return self.ensureTotalCapacityPrecise(better_capacity); return self.ensureTotalCapacityPrecise(better_capacity);
} }
/// Modify the array so that it can hold at least `new_capacity` items. /// Modify the array so that it can hold `new_capacity` items.
/// Like `ensureTotalCapacity`, but the resulting capacity is much more likely /// Like `ensureTotalCapacity`, but the resulting capacity is guaranteed
/// (but not guaranteed) to be equal to `new_capacity`. /// to be equal to `new_capacity`.
/// Invalidates pointers if additional memory is needed. /// Invalidates pointers if additional memory is needed.
pub fn ensureTotalCapacityPrecise(self: *Self, new_capacity: usize) Allocator.Error!void { pub fn ensureTotalCapacityPrecise(self: *Self, new_capacity: usize) Allocator.Error!void {
if (@sizeOf(T) == 0) { if (@sizeOf(T) == 0) {
@ -570,8 +570,8 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ
return if (alignment) |a| ([:s]align(a) T) else [:s]T; return if (alignment) |a| ([:s]align(a) T) else [:s]T;
} }
/// Initialize with capacity to hold at least num elements. /// Initialize with capacity to hold `num` elements.
/// The resulting capacity is likely to be equal to `num`. /// The resulting capacity will equal `num` exactly.
/// Deinitialize with `deinit` or use `toOwnedSlice`. /// Deinitialize with `deinit` or use `toOwnedSlice`.
pub fn initCapacity(allocator: Allocator, num: usize) Allocator.Error!Self { pub fn initCapacity(allocator: Allocator, num: usize) Allocator.Error!Self {
var self = Self{}; var self = Self{};
@ -885,9 +885,9 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ
return self.ensureTotalCapacityPrecise(allocator, better_capacity); return self.ensureTotalCapacityPrecise(allocator, better_capacity);
} }
/// Modify the array so that it can hold at least `new_capacity` items. /// Modify the array so that it can hold `new_capacity` items.
/// Like `ensureTotalCapacity`, but the resulting capacity is much more likely /// Like `ensureTotalCapacity`, but the resulting capacity is guaranteed
/// (but not guaranteed) to be equal to `new_capacity`. /// to be equal to `new_capacity`.
/// Invalidates pointers if additional memory is needed. /// Invalidates pointers if additional memory is needed.
pub fn ensureTotalCapacityPrecise(self: *Self, allocator: Allocator, new_capacity: usize) Allocator.Error!void { pub fn ensureTotalCapacityPrecise(self: *Self, allocator: Allocator, new_capacity: usize) Allocator.Error!void {
if (@sizeOf(T) == 0) { if (@sizeOf(T) == 0) {