Skip to content

Commit 53f5eee

Browse files
committed
fix: master remove HeapAllocator
1 parent cde3f58 commit 53f5eee

File tree

1 file changed

+0
-25
lines changed

1 file changed

+0
-25
lines changed

course/code/14/memory_manager.zig

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ pub fn main() !void {
44
try FixedBufferAllocator.main();
55
try ThreadSafeFixedBufferAllocator.main();
66
try ArenaAllocator.main();
7-
if (builtin.os.tag == .windows) {
8-
try HeapAllocator.main();
9-
}
107
try c_allocaotr.main();
118
try page_allocator.main();
129
try StackFallbackAllocator.main();
@@ -119,28 +116,6 @@ const ArenaAllocator = struct {
119116
// #endregion ArenaAllocator
120117
};
121118

122-
const HeapAllocator = struct {
123-
// #region HeapAllocator
124-
const std = @import("std");
125-
126-
pub fn main() !void {
127-
// 获取分配器模型
128-
var heap = std.heap.HeapAllocator.init();
129-
// 善后工作,但有一点需要注意
130-
// 这个善后工作只有在你手动指定 heapallocaotr 的 heap_handle 字段时,才有效
131-
defer heap.deinit();
132-
133-
// 获取分配器
134-
const allocator = heap.allocator();
135-
136-
// 分配内存
137-
const num = try allocator.alloc(u8, 1);
138-
// free 内存
139-
defer allocator.free(num);
140-
}
141-
// #endregion HeapAllocator
142-
};
143-
144119
const c_allocaotr = struct {
145120
// #region c_allocator
146121
const std = @import("std");

0 commit comments

Comments
 (0)