| ... | @@ -1,15 +1,7 @@ | ... | @@ -1,15 +1,7 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const json = @import("json"); | 2 | const json = @import("json"); |
| 3 | | 3 | |
| 4 | comptime { | 4 | pub export fn main() void { |
| 5 | @export(cMain, .{ .name = "main", .linkage = .strong }); | | |
| 6 | } | | |
| 7 | | | |
| 8 | fn cMain() callconv(.C) void { | | |
| 9 | main(); | | |
| 10 | } | | |
| 11 | | | |
| 12 | pub fn main() void { | | |
| 13 | // Setup an allocator that will detect leaks/use-after-free/etc | 5 | // Setup an allocator that will detect leaks/use-after-free/etc |
| 14 | var gpa = std.heap.GeneralPurposeAllocator(.{}){}; | 6 | var gpa = std.heap.GeneralPurposeAllocator(.{}){}; |
| 15 | // this will check for leaks and crash the program if it finds any | 7 | // this will check for leaks and crash the program if it finds any |
| ... | @@ -20,6 +12,6 @@ pub fn main() void { | ... | @@ -20,6 +12,6 @@ pub fn main() void { |
| 20 | const stdin = std.io.getStdIn(); | 12 | const stdin = std.io.getStdIn(); |
| 21 | | 13 | |
| 22 | // Try to parse the data | 14 | // Try to parse the data |
| 23 | var parsed = json.parse(allocator, "[stdin]", stdin.reader()) catch return; | 15 | var parsed = json.parse(allocator, "[stdin]", stdin.reader(), .{ .support_trailing_commas = true, .maximum_depth = 100 }) catch return; |
| 24 | defer parsed.deinit(allocator); | 16 | defer parsed.deinit(allocator); |
| 25 | } | 17 | } |