zig

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

commit 108b3c5673908057df7b96cec61d9bcadaa9f197 (tree)
parent e28f4a1d859bbfe2f08074159a05e03d30d2cf81
Author: Felix "xq" Queißner <xq@random-projects.net>
Date:   Tue, 23 Aug 2022 15:25:27 +0200

Improves the comment formatting.

Diffstat:
Mlib/std/heap.zig | 1-
Mlib/std/heap/memory_pool.zig | 22++++++++++------------
2 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/lib/std/heap.zig b/lib/std/heap.zig @@ -29,7 +29,6 @@ pub const MemoryPoolOptions = memory_pool.Options; /// TODO Utilize this on Windows. pub var next_mmap_addr_hint: ?[*]align(mem.page_size) u8 = null; - const CAllocator = struct { comptime { if (!builtin.link_libc) { diff --git a/lib/std/heap/memory_pool.zig b/lib/std/heap/memory_pool.zig @@ -5,15 +5,15 @@ const debug_mode = @import("builtin").mode == .Debug; pub const MemoryPoolError = error{OutOfMemory}; /// A memory pool that can allocate objects of a single type very quickly. -/// Use this instead of a general purpose allocator when you need to allocate a lot of objects -/// of the same type, as a memory pool outperforms general purpose allocators. +/// Use this when you need to allocate a lot of objects of the same type, +/// because It outperforms general purpose allocators. pub fn MemoryPool(comptime Item: type) type { return MemoryPoolAligned(Item, @alignOf(Item)); } /// A memory pool that can allocate objects of a single type very quickly. -/// Use this instead of a general purpose allocator when you need to allocate a lot of objects -/// of the same type, as a memory pool outperforms general purpose allocators. +/// Use this when you need to allocate a lot of objects of the same type, +/// because It outperforms general purpose allocators. pub fn MemoryPoolAligned(comptime Item: type, comptime alignment: u29) type { if (@alignOf(Item) == alignment) { return MemoryPoolExtra(Item, .{}); @@ -32,20 +32,18 @@ pub const Options = struct { }; /// A memory pool that can allocate objects of a single type very quickly. -/// Use this instead of a general purpose allocator when you need to allocate a lot of objects -/// of the same type, as a memory pool outperforms general purpose allocators. +/// Use this when you need to allocate a lot of objects of the same type, +/// because It outperforms general purpose allocators. pub fn MemoryPoolExtra(comptime Item: type, comptime pool_options: Options) type { return struct { const Pool = @This(); - /// Size of the memory pool items. This is not necessarily - /// the same as `@sizeOf(Item)` as the pool also uses the items for internal - /// means. + /// Size of the memory pool items. This is not necessarily the same + /// as `@sizeOf(Item)` as the pool also uses the items for internal means. pub const item_size = std.math.max(@sizeOf(Node), @sizeOf(Item)); - /// Alignment of the memory pool items. This is not necessarily - /// the same as `@alignOf(Item)` as the pool also uses the items for internal - /// means. + /// Alignment of the memory pool items. This is not necessarily the same + /// as `@alignOf(Item)` as the pool also uses the items for internal means. pub const item_alignment = std.math.max(@alignOf(Node), pool_options.alignment orelse 0); const Node = struct {