aboutsummaryrefslogtreecommitdiff
path: root/lib/std/array_list.zig
diff options
context:
space:
mode:
authorAlex Cameron <ascottcameron@gmail.com>2020-12-29 16:22:22 +1100
committerAlex Cameron <ascottcameron@gmail.com>2021-01-06 00:55:51 +1100
commit89286376c627c708e90697cb249a54feb7c827d6 (patch)
tree708169d4380f33fb0c2b5a8ef02a313a3f850c6f /lib/std/array_list.zig
parent3e8aaee829584f4893cad5c524076d2300f45f24 (diff)
downloadzig-89286376c627c708e90697cb249a54feb7c827d6.tar.gz
zig-89286376c627c708e90697cb249a54feb7c827d6.zip
std: Rename ArrayList shrink => shrinkAndFree
Diffstat (limited to 'lib/std/array_list.zig')
-rw-r--r--lib/std/array_list.zig8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/std/array_list.zig b/lib/std/array_list.zig
index 3114d1b744..53580585ad 100644
--- a/lib/std/array_list.zig
+++ b/lib/std/array_list.zig
@@ -269,7 +269,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type {
/// Reduce allocated capacity to `new_len`.
/// May invalidate element pointers.
- pub fn shrink(self: *Self, new_len: usize) void {
+ pub fn shrinkAndFree(self: *Self, new_len: usize) void {
assert(new_len <= self.items.len);
self.items = self.allocator.realloc(self.allocatedSlice(), new_len) catch |e| switch (e) {
@@ -585,7 +585,7 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ
}
/// Reduce allocated capacity to `new_len`.
- pub fn shrink(self: *Self, allocator: *Allocator, new_len: usize) void {
+ pub fn shrinkAndFree(self: *Self, allocator: *Allocator, new_len: usize) void {
assert(new_len <= self.items.len);
self.items = allocator.realloc(self.allocatedSlice(), new_len) catch |e| switch (e) {
@@ -1153,7 +1153,7 @@ test "std.ArrayList/ArrayListUnmanaged.shrink still sets length on error.OutOfMe
try list.append(2);
try list.append(3);
- list.shrink(1);
+ list.shrinkAndFree(1);
testing.expect(list.items.len == 1);
}
{
@@ -1163,7 +1163,7 @@ test "std.ArrayList/ArrayListUnmanaged.shrink still sets length on error.OutOfMe
try list.append(a, 2);
try list.append(a, 3);
- list.shrink(a, 1);
+ list.shrinkAndFree(a, 1);
testing.expect(list.items.len == 1);
}
}