| author | |
| committer | |
| log | 89286376c627c708e90697cb249a54feb7c827d6 |
| tree | 708169d4380f33fb0c2b5a8ef02a313a3f850c6f |
| parent | 3e8aaee829584f4893cad5c524076d2300f45f24 |
10 files changed, 22 insertions(+), 22 deletions(-)
lib/std/array_hash_map.zig+1-1| ... | @@ -323,7 +323,7 @@ pub fn ArrayHashMapUnmanaged( | ... | @@ -323,7 +323,7 @@ pub fn ArrayHashMapUnmanaged( |
| 323 | } | 323 | } |
| 324 | 324 | ||
| 325 | pub fn clearAndFree(self: *Self, allocator: *Allocator) void { | 325 | pub fn clearAndFree(self: *Self, allocator: *Allocator) void { |
| 326 | self.entries.shrink(allocator, 0); | 326 | self.entries.shrinkAndFree(allocator, 0); |
| 327 | if (self.index_header) |header| { | 327 | if (self.index_header) |header| { |
| 328 | header.free(allocator); | 328 | header.free(allocator); |
| 329 | self.index_header = null; | 329 | self.index_header = null; |
lib/std/array_list.zig+4-4| ... | @@ -269,7 +269,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type { | ... | @@ -269,7 +269,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type { |
| 269 | 269 | ||
| 270 | /// Reduce allocated capacity to `new_len`. | 270 | /// Reduce allocated capacity to `new_len`. |
| 271 | /// May invalidate element pointers. | 271 | /// May invalidate element pointers. |
| 272 | pub fn shrink(self: *Self, new_len: usize) void { | 272 | pub fn shrinkAndFree(self: *Self, new_len: usize) void { |
| 273 | assert(new_len <= self.items.len); | 273 | assert(new_len <= self.items.len); |
| 274 | 274 | ||
| 275 | self.items = self.allocator.realloc(self.allocatedSlice(), new_len) catch |e| switch (e) { | 275 | 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 | ... | @@ -585,7 +585,7 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ |
| 585 | } | 585 | } |
| 586 | 586 | ||
| 587 | /// Reduce allocated capacity to `new_len`. | 587 | /// Reduce allocated capacity to `new_len`. |
| 588 | pub fn shrink(self: *Self, allocator: *Allocator, new_len: usize) void { | 588 | pub fn shrinkAndFree(self: *Self, allocator: *Allocator, new_len: usize) void { |
| 589 | assert(new_len <= self.items.len); | 589 | assert(new_len <= self.items.len); |
| 590 | 590 | ||
| 591 | self.items = allocator.realloc(self.allocatedSlice(), new_len) catch |e| switch (e) { | 591 | 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 | ... | @@ -1153,7 +1153,7 @@ test "std.ArrayList/ArrayListUnmanaged.shrink still sets length on error.OutOfMe |
| 1153 | try list.append(2); | 1153 | try list.append(2); |
| 1154 | try list.append(3); | 1154 | try list.append(3); |
| 1155 | 1155 | ||
| 1156 | list.shrink(1); | 1156 | list.shrinkAndFree(1); |
| 1157 | testing.expect(list.items.len == 1); | 1157 | testing.expect(list.items.len == 1); |
| 1158 | } | 1158 | } |
| 1159 | { | 1159 | { |
| ... | @@ -1163,7 +1163,7 @@ test "std.ArrayList/ArrayListUnmanaged.shrink still sets length on error.OutOfMe | ... | @@ -1163,7 +1163,7 @@ test "std.ArrayList/ArrayListUnmanaged.shrink still sets length on error.OutOfMe |
| 1163 | try list.append(a, 2); | 1163 | try list.append(a, 2); |
| 1164 | try list.append(a, 3); | 1164 | try list.append(a, 3); |
| 1165 | 1165 | ||
| 1166 | list.shrink(a, 1); | 1166 | list.shrinkAndFree(a, 1); |
| 1167 | testing.expect(list.items.len == 1); | 1167 | testing.expect(list.items.len == 1); |
| 1168 | } | 1168 | } |
| 1169 | } | 1169 | } |
lib/std/fs.zig+1-1| ... | @@ -2186,7 +2186,7 @@ pub const Walker = struct { | ... | @@ -2186,7 +2186,7 @@ pub const Walker = struct { |
| 2186 | var top = &self.stack.items[self.stack.items.len - 1]; | 2186 | var top = &self.stack.items[self.stack.items.len - 1]; |
| 2187 | const dirname_len = top.dirname_len; | 2187 | const dirname_len = top.dirname_len; |
| 2188 | if (try top.dir_it.next()) |base| { | 2188 | if (try top.dir_it.next()) |base| { |
| 2189 | self.name_buffer.shrink(dirname_len); | 2189 | self.name_buffer.shrinkAndFree(dirname_len); |
| 2190 | try self.name_buffer.append(path.sep); | 2190 | try self.name_buffer.append(path.sep); |
| 2191 | try self.name_buffer.appendSlice(base.name); | 2191 | try self.name_buffer.appendSlice(base.name); |
| 2192 | if (base.kind == .Directory) { | 2192 | if (base.kind == .Directory) { |
lib/std/io/reader.zig+3-3| ... | @@ -76,12 +76,12 @@ pub fn Reader( | ... | @@ -76,12 +76,12 @@ pub fn Reader( |
| 76 | start_index += bytes_read; | 76 | start_index += bytes_read; |
| 77 | 77 | ||
| 78 | if (start_index - original_len > max_append_size) { | 78 | if (start_index - original_len > max_append_size) { |
| 79 | array_list.shrink(original_len + max_append_size); | 79 | array_list.shrinkAndFree(original_len + max_append_size); |
| 80 | return error.StreamTooLong; | 80 | return error.StreamTooLong; |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | if (bytes_read != dest_slice.len) { | 83 | if (bytes_read != dest_slice.len) { |
| 84 | array_list.shrink(start_index); | 84 | array_list.shrinkAndFree(start_index); |
| 85 | return; | 85 | return; |
| 86 | } | 86 | } |
| 87 | 87 | ||
| ... | @@ -111,7 +111,7 @@ pub fn Reader( | ... | @@ -111,7 +111,7 @@ pub fn Reader( |
| 111 | delimiter: u8, | 111 | delimiter: u8, |
| 112 | max_size: usize, | 112 | max_size: usize, |
| 113 | ) !void { | 113 | ) !void { |
| 114 | array_list.shrink(0); | 114 | array_list.shrinkAndFree(0); |
| 115 | while (true) { | 115 | while (true) { |
| 116 | var byte: u8 = try self.readByte(); | 116 | var byte: u8 = try self.readByte(); |
| 117 | 117 |
lib/std/json.zig+1-1| ... | @@ -1897,7 +1897,7 @@ pub const Parser = struct { | ... | @@ -1897,7 +1897,7 @@ pub const Parser = struct { |
| 1897 | 1897 | ||
| 1898 | pub fn reset(p: *Parser) void { | 1898 | pub fn reset(p: *Parser) void { |
| 1899 | p.state = .Simple; | 1899 | p.state = .Simple; |
| 1900 | p.stack.shrink(0); | 1900 | p.stack.shrinkAndFree(0); |
| 1901 | } | 1901 | } |
| 1902 | 1902 | ||
| 1903 | pub fn parse(p: *Parser, input: []const u8) !ValueTree { | 1903 | pub fn parse(p: *Parser, input: []const u8) !ValueTree { |
lib/std/math/big/int.zig+1-1| ... | @@ -607,7 +607,7 @@ pub const Mutable = struct { | ... | @@ -607,7 +607,7 @@ pub const Mutable = struct { |
| 607 | /// it will have the same length as it had when the function was called. | 607 | /// it will have the same length as it had when the function was called. |
| 608 | pub fn gcd(rma: *Mutable, x: Const, y: Const, limbs_buffer: *std.ArrayList(Limb)) !void { | 608 | pub fn gcd(rma: *Mutable, x: Const, y: Const, limbs_buffer: *std.ArrayList(Limb)) !void { |
| 609 | const prev_len = limbs_buffer.items.len; | 609 | const prev_len = limbs_buffer.items.len; |
| 610 | defer limbs_buffer.shrink(prev_len); | 610 | defer limbs_buffer.shrinkAndFree(prev_len); |
| 611 | const x_copy = if (rma.limbs.ptr == x.limbs.ptr) blk: { | 611 | const x_copy = if (rma.limbs.ptr == x.limbs.ptr) blk: { |
| 612 | const start = limbs_buffer.items.len; | 612 | const start = limbs_buffer.items.len; |
| 613 | try limbs_buffer.appendSlice(x.limbs); | 613 | try limbs_buffer.appendSlice(x.limbs); |
lib/std/net.zig+2-2| ... | @@ -1200,13 +1200,13 @@ fn linuxLookupNameFromDnsSearch( | ... | @@ -1200,13 +1200,13 @@ fn linuxLookupNameFromDnsSearch( |
| 1200 | 1200 | ||
| 1201 | var tok_it = mem.tokenize(search, " \t"); | 1201 | var tok_it = mem.tokenize(search, " \t"); |
| 1202 | while (tok_it.next()) |tok| { | 1202 | while (tok_it.next()) |tok| { |
| 1203 | canon.shrink(canon_name.len + 1); | 1203 | canon.shrinkAndFree(canon_name.len + 1); |
| 1204 | try canon.appendSlice(tok); | 1204 | try canon.appendSlice(tok); |
| 1205 | try linuxLookupNameFromDns(addrs, canon, canon.items, family, rc, port); | 1205 | try linuxLookupNameFromDns(addrs, canon, canon.items, family, rc, port); |
| 1206 | if (addrs.items.len != 0) return; | 1206 | if (addrs.items.len != 0) return; |
| 1207 | } | 1207 | } |
| 1208 | 1208 | ||
| 1209 | canon.shrink(canon_name.len); | 1209 | canon.shrinkAndFree(canon_name.len); |
| 1210 | return linuxLookupNameFromDns(addrs, canon, name, family, rc, port); | 1210 | return linuxLookupNameFromDns(addrs, canon, name, family, rc, port); |
| 1211 | } | 1211 | } |
| 1212 | 1212 |
src/Compilation.zig+1-1| ... | @@ -735,7 +735,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { | ... | @@ -735,7 +735,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { |
| 735 | } | 735 | } |
| 736 | assert(mem.endsWith(u8, buf.items, ",")); | 736 | assert(mem.endsWith(u8, buf.items, ",")); |
| 737 | buf.items[buf.items.len - 1] = 0; | 737 | buf.items[buf.items.len - 1] = 0; |
| 738 | buf.shrink(buf.items.len); | 738 | buf.shrinkAndFree(buf.items.len); |
| 739 | break :blk buf.items[0 .. buf.items.len - 1 :0].ptr; | 739 | break :blk buf.items[0 .. buf.items.len - 1 :0].ptr; |
| 740 | } else null; | 740 | } else null; |
| 741 | 741 |
src/libc_installation.zig+3-3| ... | @@ -337,7 +337,7 @@ pub const LibCInstallation = struct { | ... | @@ -337,7 +337,7 @@ pub const LibCInstallation = struct { |
| 337 | defer result_buf.deinit(); | 337 | defer result_buf.deinit(); |
| 338 | 338 | ||
| 339 | for (searches) |search| { | 339 | for (searches) |search| { |
| 340 | result_buf.shrink(0); | 340 | result_buf.shrinkAndFree(0); |
| 341 | try result_buf.outStream().print("{s}\\Include\\{s}\\ucrt", .{ search.path, search.version }); | 341 | try result_buf.outStream().print("{s}\\Include\\{s}\\ucrt", .{ search.path, search.version }); |
| 342 | 342 | ||
| 343 | var dir = fs.cwd().openDir(result_buf.items, .{}) catch |err| switch (err) { | 343 | var dir = fs.cwd().openDir(result_buf.items, .{}) catch |err| switch (err) { |
| ... | @@ -383,7 +383,7 @@ pub const LibCInstallation = struct { | ... | @@ -383,7 +383,7 @@ pub const LibCInstallation = struct { |
| 383 | }; | 383 | }; |
| 384 | 384 | ||
| 385 | for (searches) |search| { | 385 | for (searches) |search| { |
| 386 | result_buf.shrink(0); | 386 | result_buf.shrinkAndFree(0); |
| 387 | try result_buf.outStream().print("{s}\\Lib\\{s}\\ucrt\\{s}", .{ search.path, search.version, arch_sub_dir }); | 387 | try result_buf.outStream().print("{s}\\Lib\\{s}\\ucrt\\{s}", .{ search.path, search.version, arch_sub_dir }); |
| 388 | 388 | ||
| 389 | var dir = fs.cwd().openDir(result_buf.items, .{}) catch |err| switch (err) { | 389 | var dir = fs.cwd().openDir(result_buf.items, .{}) catch |err| switch (err) { |
| ... | @@ -437,7 +437,7 @@ pub const LibCInstallation = struct { | ... | @@ -437,7 +437,7 @@ pub const LibCInstallation = struct { |
| 437 | }; | 437 | }; |
| 438 | 438 | ||
| 439 | for (searches) |search| { | 439 | for (searches) |search| { |
| 440 | result_buf.shrink(0); | 440 | result_buf.shrinkAndFree(0); |
| 441 | const stream = result_buf.outStream(); | 441 | const stream = result_buf.outStream(); |
| 442 | try stream.print("{s}\\Lib\\{s}\\um\\{s}", .{ search.path, search.version, arch_sub_dir }); | 442 | try stream.print("{s}\\Lib\\{s}\\um\\{s}", .{ search.path, search.version, arch_sub_dir }); |
| 443 | 443 |
src/translate_c.zig+5-5| ... | @@ -2846,7 +2846,7 @@ fn transCase( | ... | @@ -2846,7 +2846,7 @@ fn transCase( |
| 2846 | 2846 | ||
| 2847 | // take all pending statements | 2847 | // take all pending statements |
| 2848 | try switch_scope.pending_block.statements.appendSlice(block_scope.statements.items); | 2848 | try switch_scope.pending_block.statements.appendSlice(block_scope.statements.items); |
| 2849 | block_scope.statements.shrink(0); | 2849 | block_scope.statements.shrinkAndFree(0); |
| 2850 | 2850 | ||
| 2851 | const pending_node = try switch_scope.pending_block.complete(rp.c); | 2851 | const pending_node = try switch_scope.pending_block.complete(rp.c); |
| 2852 | switch_scope.pending_block.deinit(); | 2852 | switch_scope.pending_block.deinit(); |
| ... | @@ -2884,7 +2884,7 @@ fn transDefault( | ... | @@ -2884,7 +2884,7 @@ fn transDefault( |
| 2884 | 2884 | ||
| 2885 | // take all pending statements | 2885 | // take all pending statements |
| 2886 | try switch_scope.pending_block.statements.appendSlice(block_scope.statements.items); | 2886 | try switch_scope.pending_block.statements.appendSlice(block_scope.statements.items); |
| 2887 | block_scope.statements.shrink(0); | 2887 | block_scope.statements.shrinkAndFree(0); |
| 2888 | 2888 | ||
| 2889 | const pending_node = try switch_scope.pending_block.complete(rp.c); | 2889 | const pending_node = try switch_scope.pending_block.complete(rp.c); |
| 2890 | switch_scope.pending_block.deinit(); | 2890 | switch_scope.pending_block.deinit(); |
| ... | @@ -4773,9 +4773,9 @@ const RestorePoint = struct { | ... | @@ -4773,9 +4773,9 @@ const RestorePoint = struct { |
| 4773 | src_buf_index: usize, | 4773 | src_buf_index: usize, |
| 4774 | 4774 | ||
| 4775 | fn activate(self: RestorePoint) void { | 4775 | fn activate(self: RestorePoint) void { |
| 4776 | self.c.token_ids.shrink(self.c.gpa, self.token_index); | 4776 | self.c.token_ids.shrinkAndFree(self.c.gpa, self.token_index); |
| 4777 | self.c.token_locs.shrink(self.c.gpa, self.token_index); | 4777 | self.c.token_locs.shrinkAndFree(self.c.gpa, self.token_index); |
| 4778 | self.c.source_buffer.shrink(self.src_buf_index); | 4778 | self.c.source_buffer.shrinkAndFree(self.src_buf_index); |
| 4779 | } | 4779 | } |
| 4780 | }; | 4780 | }; |
| 4781 | 4781 |