mirror of
https://github.com/ziglang/zig.git
synced 2025-12-15 18:53:07 +00:00
Remove resize. Adding uninitialized memory at the end of the items would break the heap property.
This commit is contained in:
parent
9a09ebb1b9
commit
5bfd9238de
@ -377,11 +377,6 @@ pub fn PriorityDequeue(comptime T: type) type {
|
|||||||
self.items = try self.allocator.realloc(self.items, better_capacity);
|
self.items = try self.allocator.realloc(self.items, better_capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn resize(self: *Self, new_len: usize) !void {
|
|
||||||
try self.ensureCapacity(new_len);
|
|
||||||
self.len = new_len;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Reduce allocated capacity to `new_len`.
|
/// Reduce allocated capacity to `new_len`.
|
||||||
pub fn shrinkAndFree(self: *Self, new_len: usize) void {
|
pub fn shrinkAndFree(self: *Self, new_len: usize) void {
|
||||||
assert(new_len <= self.items.len);
|
assert(new_len <= self.items.len);
|
||||||
|
|||||||
@ -187,11 +187,6 @@ pub fn PriorityQueue(comptime T: type) type {
|
|||||||
self.items = try self.allocator.realloc(self.items, better_capacity);
|
self.items = try self.allocator.realloc(self.items, better_capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn resize(self: *Self, new_len: usize) !void {
|
|
||||||
try self.ensureCapacity(new_len);
|
|
||||||
self.len = new_len;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Reduce allocated capacity to `new_len`.
|
/// Reduce allocated capacity to `new_len`.
|
||||||
pub fn shrinkAndFree(self: *Self, new_len: usize) void {
|
pub fn shrinkAndFree(self: *Self, new_len: usize) void {
|
||||||
assert(new_len <= self.items.len);
|
assert(new_len <= self.items.len);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user