diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-11-30 18:48:31 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-30 18:48:31 -0800 |
| commit | 7355a201336c8e3892427e5932fe5cdd46cf96df (patch) | |
| tree | 4ccec922634586847d02f2324d0db75f25200188 /src/codegen/c.zig | |
| parent | dd62a6d2e8de522187fd096354e7156cca1821c5 (diff) | |
| parent | 066eaa5e9cbfde172449f6d95bb884c7d86ac10c (diff) | |
| download | zig-7355a201336c8e3892427e5932fe5cdd46cf96df.tar.gz zig-7355a201336c8e3892427e5932fe5cdd46cf96df.zip | |
Merge pull request #10055 from leecannon/allocator_refactor
Allocgate
Diffstat (limited to 'src/codegen/c.zig')
| -rw-r--r-- | src/codegen/c.zig | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig index 11c899bdd2..f54ae7f76d 100644 --- a/src/codegen/c.zig +++ b/src/codegen/c.zig @@ -163,14 +163,14 @@ pub const Object = struct { /// This data is available both when outputting .c code and when outputting an .h file. pub const DeclGen = struct { - gpa: *std.mem.Allocator, + gpa: std.mem.Allocator, module: *Module, decl: *Decl, fwd_decl: std.ArrayList(u8), error_msg: ?*Module.ErrorMsg, /// The key of this map is Type which has references to typedefs_arena. typedefs: TypedefMap, - typedefs_arena: *std.mem.Allocator, + typedefs_arena: std.mem.Allocator, fn fail(dg: *DeclGen, comptime format: []const u8, args: anytype) error{ AnalysisFail, OutOfMemory } { @setCold(true); @@ -390,6 +390,7 @@ pub const DeclGen = struct { // Fall back to generic implementation. var arena = std.heap.ArenaAllocator.init(dg.module.gpa); defer arena.deinit(); + const arena_allocator = arena.allocator(); try writer.writeAll("{"); var index: usize = 0; @@ -397,7 +398,7 @@ pub const DeclGen = struct { const elem_ty = ty.elemType(); while (index < len) : (index += 1) { if (index != 0) try writer.writeAll(","); - const elem_val = try val.elemValue(&arena.allocator, index); + const elem_val = try val.elemValue(arena_allocator, index); try dg.renderValue(writer, elem_ty, elem_val); } if (ty.sentinel()) |sentinel_val| { |
