zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 5bfd9238de82b8f66ba4834bcf7aa120e42fe6ca (tree)
parent 9a09ebb1b92f33913bdcc16e9d978fb6e5a820f1
Author: Zander Khan <git@zander.xyz>
Date:   Sun, 17 Jan 2021 14:43:38 +0000

Remove `resize`. Adding uninitialized memory at the end of the `items` would break the heap property.

Diffstat:
Mlib/std/priority_dequeue.zig | 5-----
Mlib/std/priority_queue.zig | 5-----
2 files changed, 0 insertions(+), 10 deletions(-)

diff --git a/lib/std/priority_dequeue.zig b/lib/std/priority_dequeue.zig @@ -377,11 +377,6 @@ pub fn PriorityDequeue(comptime T: type) type { 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`. pub fn shrinkAndFree(self: *Self, new_len: usize) void { assert(new_len <= self.items.len); diff --git a/lib/std/priority_queue.zig b/lib/std/priority_queue.zig @@ -187,11 +187,6 @@ pub fn PriorityQueue(comptime T: type) type { 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`. pub fn shrinkAndFree(self: *Self, new_len: usize) void { assert(new_len <= self.items.len);