summaryrefslogtreecommitdiff
path: root/util/file.zig
diff options
context:
space:
mode:
authorChristian Segundo2022-12-03 11:51:40 +0100
committerChristian Segundo2022-12-03 11:51:40 +0100
commit78fa87cd43cd18f2f9ec4a04c45bcb8036143fd8 (patch)
tree56af86be97e50d4f8c6926e27eea84d15ba2f2e6 /util/file.zig
parent6990eb44ae6111ac18667e416dc4dc2883c50f25 (diff)
downloadadvent-of-zig-2022-78fa87cd43cd18f2f9ec4a04c45bcb8036143fd8.tar.gz
add day 3
Diffstat (limited to 'util/file.zig')
-rw-r--r--util/file.zig4
1 files changed, 3 insertions, 1 deletions
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).?;
}