zig

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

commit b75d86027d589be632a831ec55565230818dc4ef (tree)
parent b03345f32a5ba2849ddbeeae0e31e0e77ca01b01
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Mon, 18 Apr 2022 05:28:31 -0700

stage2: avoid binary bloat from GeneralPurposeAllocator

In the case of not using it.

Diffstat:
Msrc/main.zig | 7+++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/main.zig b/src/main.zig @@ -135,10 +135,9 @@ var general_purpose_allocator = std.heap.GeneralPurposeAllocator(.{ pub fn main() anyerror!void { crash_report.initialize(); - var gpa_need_deinit = false; + const use_gpa = build_options.force_gpa or !builtin.link_libc; const gpa = gpa: { - if (build_options.force_gpa or !builtin.link_libc) { - gpa_need_deinit = true; + if (use_gpa) { break :gpa general_purpose_allocator.allocator(); } // We would prefer to use raw libc allocator here, but cannot @@ -148,7 +147,7 @@ pub fn main() anyerror!void { } break :gpa std.heap.raw_c_allocator; }; - defer if (gpa_need_deinit) { + defer if (use_gpa) { _ = general_purpose_allocator.deinit(); }; var arena_instance = std.heap.ArenaAllocator.init(gpa);