authorgravatar for xq@random-projects.netFelix "xq" Queißner <xq@random-projects.net> 2022-08-23 15:25:27+02:00
committergravatar for xq@random-projects.netFelix "xq" Queißner <xq@random-projects.net> 2022-12-15 10:16:28+01:00
log108b3c5673908057df7b96cec61d9bcadaa9f197
tree6c79aeb0bf24f06cb265d5d371a0b69b33a3e8b9
parente28f4a1d859bbfe2f08074159a05e03d30d2cf81

Improves the comment formatting.


2 files changed, 10 insertions(+), 13 deletions(-)

lib/std/heap.zig-1
...@@ -29,7 +29,6 @@ pub const MemoryPoolOptions = memory_pool.Options;...@@ -29,7 +29,6 @@ pub const MemoryPoolOptions = memory_pool.Options;
29/// TODO Utilize this on Windows.29/// TODO Utilize this on Windows.
30pub var next_mmap_addr_hint: ?[*]align(mem.page_size) u8 = null;30pub var next_mmap_addr_hint: ?[*]align(mem.page_size) u8 = null;
3131
32
33const CAllocator = struct {32const CAllocator = struct {
34 comptime {33 comptime {
35 if (!builtin.link_libc) {34 if (!builtin.link_libc) {
lib/std/heap/memory_pool.zig+10-12
...@@ -5,15 +5,15 @@ const debug_mode = @import("builtin").mode == .Debug;...@@ -5,15 +5,15 @@ const debug_mode = @import("builtin").mode == .Debug;
5pub const MemoryPoolError = error{OutOfMemory};5pub const MemoryPoolError = error{OutOfMemory};
66
7/// A memory pool that can allocate objects of a single type very quickly.7/// A memory pool that can allocate objects of a single type very quickly.
8/// Use this instead of a general purpose allocator when you need to allocate a lot of objects8/// Use this when you need to allocate a lot of objects of the same type,
9/// of the same type, as a memory pool outperforms general purpose allocators.9/// because It outperforms general purpose allocators.
10pub fn MemoryPool(comptime Item: type) type {10pub fn MemoryPool(comptime Item: type) type {
11 return MemoryPoolAligned(Item, @alignOf(Item));11 return MemoryPoolAligned(Item, @alignOf(Item));
12}12}
1313
14/// A memory pool that can allocate objects of a single type very quickly.14/// A memory pool that can allocate objects of a single type very quickly.
15/// Use this instead of a general purpose allocator when you need to allocate a lot of objects15/// Use this when you need to allocate a lot of objects of the same type,
16/// of the same type, as a memory pool outperforms general purpose allocators.16/// because It outperforms general purpose allocators.
17pub fn MemoryPoolAligned(comptime Item: type, comptime alignment: u29) type {17pub fn MemoryPoolAligned(comptime Item: type, comptime alignment: u29) type {
18 if (@alignOf(Item) == alignment) {18 if (@alignOf(Item) == alignment) {
19 return MemoryPoolExtra(Item, .{});19 return MemoryPoolExtra(Item, .{});
...@@ -32,20 +32,18 @@ pub const Options = struct {...@@ -32,20 +32,18 @@ pub const Options = struct {
32};32};
3333
34/// A memory pool that can allocate objects of a single type very quickly.34/// A memory pool that can allocate objects of a single type very quickly.
35/// Use this instead of a general purpose allocator when you need to allocate a lot of objects35/// Use this when you need to allocate a lot of objects of the same type,
36/// of the same type, as a memory pool outperforms general purpose allocators.36/// because It outperforms general purpose allocators.
37pub fn MemoryPoolExtra(comptime Item: type, comptime pool_options: Options) type {37pub fn MemoryPoolExtra(comptime Item: type, comptime pool_options: Options) type {
38 return struct {38 return struct {
39 const Pool = @This();39 const Pool = @This();
4040
41 /// Size of the memory pool items. This is not necessarily41 /// Size of the memory pool items. This is not necessarily the same
42 /// the same as `@sizeOf(Item)` as the pool also uses the items for internal42 /// as `@sizeOf(Item)` as the pool also uses the items for internal means.
43 /// means.
44 pub const item_size = std.math.max(@sizeOf(Node), @sizeOf(Item));43 pub const item_size = std.math.max(@sizeOf(Node), @sizeOf(Item));
4544
46 /// Alignment of the memory pool items. This is not necessarily45 /// Alignment of the memory pool items. This is not necessarily the same
47 /// the same as `@alignOf(Item)` as the pool also uses the items for internal46 /// as `@alignOf(Item)` as the pool also uses the items for internal means.
48 /// means.
49 pub const item_alignment = std.math.max(@alignOf(Node), pool_options.alignment orelse 0);47 pub const item_alignment = std.math.max(@alignOf(Node), pool_options.alignment orelse 0);
5048
51 const Node = struct {49 const Node = struct {