This commit is contained in:
krahets
2023-02-10 01:03:37 +08:00
parent 49d39ff871
commit 76dcc6cbd3
7 changed files with 265 additions and 71 deletions

View File

@@ -853,7 +853,7 @@ comments: true
mem_arena: ?std.heap.ArenaAllocator = null,
mem_allocator: std.mem.Allocator = undefined, // 内存分配器
// 构造函数(分配内存+初始化队列)
// 构造方法(分配内存+初始化队列)
pub fn init(self: *Self, allocator: std.mem.Allocator) !void {
if (self.mem_arena == null) {
self.mem_arena = std.heap.ArenaAllocator.init(allocator);
@@ -864,7 +864,7 @@ comments: true
self.queSize = 0;
}
// 析构函数(释放内存)
// 析构方法(释放内存)
pub fn deinit(self: *Self) void {
if (self.mem_arena == null) return;
self.mem_arena.?.deinit();
@@ -1540,7 +1540,7 @@ comments: true
mem_arena: ?std.heap.ArenaAllocator = null,
mem_allocator: std.mem.Allocator = undefined, // 内存分配器
// 构造函数(分配内存+初始化数组)
// 构造方法(分配内存+初始化数组)
pub fn init(self: *Self, allocator: std.mem.Allocator, cap: usize) !void {
if (self.mem_arena == null) {
self.mem_arena = std.heap.ArenaAllocator.init(allocator);
@@ -1551,7 +1551,7 @@ comments: true
std.mem.set(T, self.nums, @as(T, 0));
}
// 析构函数(释放内存)
// 析构方法(释放内存)
pub fn deinit(self: *Self) void {
if (self.mem_arena == null) return;
self.mem_arena.?.deinit();