From 78fa87cd43cd18f2f9ec4a04c45bcb8036143fd8 Mon Sep 17 00:00:00 2001 From: Christian Segundo Date: Sat, 3 Dec 2022 11:51:40 +0100 Subject: add day 3 --- util/file.zig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'util/file.zig') diff --git a/util/file.zig b/util/file.zig index 90849e9..c63422a 100644 --- a/util/file.zig +++ b/util/file.zig @@ -8,8 +8,10 @@ pub fn slurp(allocator: std.mem.Allocator, file_path: []const u8) ![]u8 { const file = try std.fs.openFileAbsolute(path, .{}); defer file.close(); - return try file.readToEndAlloc( + var buf = try file.readToEndAlloc( allocator, (try file.stat()).size, ); + + return allocator.resize(buf, buf.len-1).?; } -- cgit v1.2.3